add select_backend module

This commit is contained in:
andri lim 2018-12-27 09:59:06 +07:00 committed by zah
parent 0487720769
commit 96b18cfce3
4 changed files with 13 additions and 30 deletions

View File

@ -0,0 +1,10 @@
const nimbus_db_backend {.strdefine.} = "rocksdb"
when nimbus_db_backend == "sqlite":
import ./backends/sqlite_backend as database_backend
elif nimbus_db_backend == "rocksdb":
import ./backends/rocksdb_backend as database_backend
else:
import ./backends/lmdb_backend as database_backend
export database_backend

View File

@ -8,22 +8,13 @@
# those terms. # those terms.
import import
os, strutils, net, eth_common, db/[storage_types, db_chain], os, strutils, net, eth_common, db/[storage_types, db_chain, select_backend],
asyncdispatch2, json_rpc/rpcserver, eth_keys, chronicles, asyncdispatch2, json_rpc/rpcserver, eth_keys, chronicles,
eth_p2p, eth_p2p/rlpx_protocols/[eth_protocol, les_protocol], eth_p2p, eth_p2p/rlpx_protocols/[eth_protocol, les_protocol],
eth_p2p/blockchain_sync, eth_p2p/blockchain_sync,
config, genesis, rpc/[common, p2p, debug, whisper], p2p/chain, config, genesis, rpc/[common, p2p, debug, whisper], p2p/chain,
eth_trie/db eth_trie/db
const nimbus_db_backend {.strdefine.} = "rocksdb"
when nimbus_db_backend == "sqlite":
import ../nimbus/db/backends/sqlite_backend
elif nimbus_db_backend == "rocksdb":
import ../nimbus/db/backends/rocksdb_backend
else:
import ../nimbus/db/backends/lmdb_backend
## TODO: ## TODO:
## * No IPv6 support ## * No IPv6 support
## * No multiple bind addresses support ## * No multiple bind addresses support

View File

@ -1,18 +1,9 @@
import import
json, os, eth_common, stint, chronicles, byteutils, nimcrypto, rlp, json, os, eth_common, stint, chronicles, byteutils, nimcrypto, rlp,
eth_trie/[db], ../nimbus/db/[db_chain, capturedb, storage_types], eth_trie/[db], ../nimbus/db/[db_chain, capturedb, storage_types, select_backend],
../nimbus/[tracer, vm_types, config], ../nimbus/[tracer, vm_types, config],
../nimbus/p2p/chain ../nimbus/p2p/chain
const nimbus_db_backend {.strdefine.} = "rocksdb"
when nimbus_db_backend == "sqlite":
import ../nimbus/db/backends/sqlite_backend
elif nimbus_db_backend == "rocksdb":
import ../nimbus/db/backends/rocksdb_backend
else:
import ../nimbus/db/backends/lmdb_backend
proc putCanonicalHead(chainDB: BaseChainDB, header: BlockHeader) = proc putCanonicalHead(chainDB: BaseChainDB, header: BlockHeader) =
var headerHash = rlpHash(header) var headerHash = rlpHash(header)
chainDB.db.put(genericHashKey(headerHash).toOpenArray, rlp.encode(header)) chainDB.db.put(genericHashKey(headerHash).toOpenArray, rlp.encode(header))

View File

@ -1,17 +1,8 @@
import import
json, os, eth_common, stint, chronicles, byteutils, nimcrypto, json, os, eth_common, stint, chronicles, byteutils, nimcrypto,
eth_trie/[db], ../nimbus/db/[db_chain, capturedb], eth_trie/[db], ../nimbus/db/[db_chain, capturedb, select_backend],
../nimbus/[tracer, vm_types, config] ../nimbus/[tracer, vm_types, config]
const nimbus_db_backend {.strdefine.} = "rocksdb"
when nimbus_db_backend == "sqlite":
import ../nimbus/db/backends/sqlite_backend
elif nimbus_db_backend == "rocksdb":
import ../nimbus/db/backends/rocksdb_backend
else:
import ../nimbus/db/backends/lmdb_backend
proc dumpTest(chainDB: BaseChainDB, blockNumber: int) = proc dumpTest(chainDB: BaseChainDB, blockNumber: int) =
let let
blockNumber = blockNumber.u256 blockNumber = blockNumber.u256