Write Protocol version to the db so we can perform sanity checks
This commit is contained in:
parent
a9f9a59416
commit
836ed9d6b7
12
ethereum.go
12
ethereum.go
@ -90,7 +90,6 @@ type Ethereum struct {
|
||||
}
|
||||
|
||||
func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager *ethcrypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) {
|
||||
|
||||
var err error
|
||||
var nat NAT
|
||||
|
||||
@ -101,6 +100,8 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager
|
||||
}
|
||||
}
|
||||
|
||||
bootstrapDb(db)
|
||||
|
||||
ethutil.Config.Db = db
|
||||
|
||||
nonce, _ := ethutil.RandomUint64()
|
||||
@ -534,3 +535,12 @@ out:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func bootstrapDb(db ethutil.Database) {
|
||||
d, _ := db.Get([]byte("ProtocolVersion"))
|
||||
protov := ethutil.NewValue(d).Uint()
|
||||
|
||||
if protov == 0 {
|
||||
db.Put([]byte("ProtocolVersion"), ethutil.NewValue(ProtocolVersion).Bytes())
|
||||
}
|
||||
}
|
||||
|
@ -141,6 +141,8 @@ func (val *Value) Bytes() []byte {
|
||||
return []byte(s)
|
||||
} else if s, ok := val.Val.(*big.Int); ok {
|
||||
return s.Bytes()
|
||||
} else {
|
||||
return big.NewInt(val.Int()).Bytes()
|
||||
}
|
||||
|
||||
return []byte{}
|
||||
|
Loading…
Reference in New Issue
Block a user