aboutsummaryrefslogtreecommitdiffstats
path: root/core/database_util.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/database_util.go')
-rw-r--r--core/database_util.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/database_util.go b/core/database_util.go
index fbcce3e8c..2dc113e29 100644
--- a/core/database_util.go
+++ b/core/database_util.go
@@ -582,3 +582,17 @@ func GetMipmapBloom(db ethdb.Database, number, level uint64) types.Bloom {
bloomDat, _ := db.Get(mipmapKey(number, level))
return types.BytesToBloom(bloomDat)
}
+
+// GetBlockChainVersion reads the version number from db.
+func GetBlockChainVersion(db ethdb.Database) int {
+ var vsn uint
+ enc, _ := db.Get([]byte("BlockchainVersion"))
+ rlp.DecodeBytes(enc, &vsn)
+ return int(vsn)
+}
+
+// WriteBlockChainVersion writes vsn as the version number to db.
+func WriteBlockChainVersion(db ethdb.Database, vsn int) {
+ enc, _ := rlp.EncodeToBytes(uint(vsn))
+ db.Put([]byte("BlockchainVersion"), enc)
+}