aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-22 17:34:59 +0800
committerobscuren <geffobscura@gmail.com>2014-08-22 17:34:59 +0800
commit836ed9d6b70e3ae928624f9ed81ed206a66b85b8 (patch)
treee6f267f3cac06ef76bef339168e06e92215d5791 /ethereum.go
parenta9f9a594160405737657083476535f3e48df1558 (diff)
downloaddexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.tar
dexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.tar.gz
dexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.tar.bz2
dexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.tar.lz
dexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.tar.xz
dexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.tar.zst
dexon-836ed9d6b70e3ae928624f9ed81ed206a66b85b8.zip
Write Protocol version to the db so we can perform sanity checks
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/ethereum.go b/ethereum.go
index 1e1891589..4c5e13b6d 100644
--- a/ethereum.go
+++ b/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())
+ }
+}