mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-03 15:55:47 +00:00
move initializeEmptyDb to genesis.nim
This commit is contained in:
parent
7190b218de
commit
0c887b3711
@ -8,7 +8,7 @@
|
|||||||
import
|
import
|
||||||
tables, sequtils, algorithm,
|
tables, sequtils, algorithm,
|
||||||
rlp, ranges, state_db, nimcrypto, eth_trie/[hexary, db], eth_common, byteutils, chronicles,
|
rlp, ranges, state_db, nimcrypto, eth_trie/[hexary, db], eth_common, byteutils, chronicles,
|
||||||
../errors, ../block_types, ../utils/header, ../constants, ./storage_types.nim
|
../errors, ../block_types, ../utils/header, ../constants, ./storage_types
|
||||||
|
|
||||||
type
|
type
|
||||||
BaseChainDB* = ref object
|
BaseChainDB* = ref object
|
||||||
|
@ -104,3 +104,11 @@ proc commit*(g: Genesis, db: BaseChainDB) =
|
|||||||
let b = g.toBlock(db)
|
let b = g.toBlock(db)
|
||||||
assert(b.blockNumber == 0, "can't commit genesis block with number > 0")
|
assert(b.blockNumber == 0, "can't commit genesis block with number > 0")
|
||||||
discard db.persistHeaderToDb(b)
|
discard db.persistHeaderToDb(b)
|
||||||
|
|
||||||
|
proc initializeEmptyDb*(db: BaseChainDB) =
|
||||||
|
trace "Writing genesis to DB"
|
||||||
|
let networkId = getConfiguration().net.networkId.toPublicNetwork()
|
||||||
|
if networkId == CustomNet:
|
||||||
|
raise newException(Exception, "Custom genesis not implemented")
|
||||||
|
else:
|
||||||
|
defaultGenesisBlockForNetwork(networkId).commit(db)
|
||||||
|
@ -35,14 +35,6 @@ type
|
|||||||
ethNode*: EthereumNode
|
ethNode*: EthereumNode
|
||||||
state*: NimbusState
|
state*: NimbusState
|
||||||
|
|
||||||
proc initializeEmptyDb(db: BaseChainDB) =
|
|
||||||
trace "Writing genesis to DB"
|
|
||||||
let networkId = getConfiguration().net.networkId.toPublicNetwork()
|
|
||||||
if networkId == CustomNet:
|
|
||||||
raise newException(Exception, "Custom genesis not implemented")
|
|
||||||
else:
|
|
||||||
defaultGenesisBlockForNetwork(networkId).commit(db)
|
|
||||||
|
|
||||||
proc start(): NimbusObject =
|
proc start(): NimbusObject =
|
||||||
var nimbus = NimbusObject()
|
var nimbus = NimbusObject()
|
||||||
var conf = getConfiguration()
|
var conf = getConfiguration()
|
||||||
|
@ -10,15 +10,6 @@ import
|
|||||||
../nimbus/[genesis, utils, config],
|
../nimbus/[genesis, utils, config],
|
||||||
../nimbus/p2p/chain
|
../nimbus/p2p/chain
|
||||||
|
|
||||||
# TODO: move this one and the one in nimbus.nim to db_chain.nim
|
|
||||||
proc initializeEmptyDb(db: BaseChainDB) =
|
|
||||||
echo "Writing genesis to DB"
|
|
||||||
let networkId = getConfiguration().net.networkId.toPublicNetwork()
|
|
||||||
if networkId == CustomNet:
|
|
||||||
raise newException(Exception, "Custom genesis not implemented")
|
|
||||||
else:
|
|
||||||
defaultGenesisBlockForNetwork(networkId).commit(db)
|
|
||||||
|
|
||||||
const
|
const
|
||||||
manualCommit = nimbus_db_backend == "lmdb"
|
manualCommit = nimbus_db_backend == "lmdb"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user