mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-02 15:24:01 +00:00
Allow dbBackend == none to compile (#1996)
* Allow dbBackend == none to compile * Fix copyright year
This commit is contained in:
parent
c635e160d9
commit
09f95962ef
@ -1,5 +1,5 @@
|
|||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2023 Status Research & Development GmbH
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -17,11 +17,18 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
../aristo,
|
../aristo,
|
||||||
./backend/[aristo_rocksdb, legacy_rocksdb],
|
./memory_only,
|
||||||
./memory_only
|
../select_backend
|
||||||
|
|
||||||
|
export
|
||||||
|
memory_only
|
||||||
|
|
||||||
|
# Allow hive sim to compile with dbBackend == none
|
||||||
|
when dbBackend == rocksdb:
|
||||||
|
import
|
||||||
|
./backend/[aristo_rocksdb, legacy_rocksdb]
|
||||||
|
|
||||||
export
|
export
|
||||||
memory_only,
|
|
||||||
toRocksStoreRef
|
toRocksStoreRef
|
||||||
|
|
||||||
proc newCoreDbRef*(
|
proc newCoreDbRef*(
|
||||||
@ -32,6 +39,7 @@ proc newCoreDbRef*(
|
|||||||
##
|
##
|
||||||
## Note: Using legacy notation `newCoreDbRef()` rather than
|
## Note: Using legacy notation `newCoreDbRef()` rather than
|
||||||
## `CoreDbRef.init()` because of compiler coughing.
|
## `CoreDbRef.init()` because of compiler coughing.
|
||||||
|
when dbBackend == rocksdb:
|
||||||
when dbType == LegacyDbPersistent:
|
when dbType == LegacyDbPersistent:
|
||||||
newLegacyPersistentCoreDbRef path
|
newLegacyPersistentCoreDbRef path
|
||||||
|
|
||||||
@ -50,6 +58,7 @@ proc newCoreDbRef*(
|
|||||||
##
|
##
|
||||||
## Note: Using legacy notation `newCoreDbRef()` rather than
|
## Note: Using legacy notation `newCoreDbRef()` rather than
|
||||||
## `CoreDbRef.init()` because of compiler coughing.
|
## `CoreDbRef.init()` because of compiler coughing.
|
||||||
|
when dbBackend == rocksdb:
|
||||||
when dbType == AristoDbRocks:
|
when dbType == AristoDbRocks:
|
||||||
newAristoRocksDbCoreDbRef(path, qlr)
|
newAristoRocksDbCoreDbRef(path, qlr)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# nimbus-eth1
|
# nimbus-eth1
|
||||||
# Copyright (c) 2021 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -20,6 +20,9 @@ import
|
|||||||
hexary_interpolate, hexary_inspect, hexary_paths, snapdb_desc,
|
hexary_interpolate, hexary_inspect, hexary_paths, snapdb_desc,
|
||||||
snapdb_persistent]
|
snapdb_persistent]
|
||||||
|
|
||||||
|
import
|
||||||
|
../../../../db/select_backend
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "snap-db"
|
topics = "snap-db"
|
||||||
|
|
||||||
@ -63,6 +66,7 @@ proc persistentAccounts(
|
|||||||
): Result[void,HexaryError]
|
): Result[void,HexaryError]
|
||||||
{.gcsafe, raises: [OSError,IOError,KeyError].} =
|
{.gcsafe, raises: [OSError,IOError,KeyError].} =
|
||||||
## Store accounts trie table on databse
|
## Store accounts trie table on databse
|
||||||
|
when dbBackend == rocksdb:
|
||||||
if ps.rockDb.isNil:
|
if ps.rockDb.isNil:
|
||||||
let rc = db.persistentAccountsPut(ps.kvDb)
|
let rc = db.persistentAccountsPut(ps.kvDb)
|
||||||
if rc.isErr: return rc
|
if rc.isErr: return rc
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# nimbus-eth1
|
# nimbus-eth1
|
||||||
# Copyright (c) 2021 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -16,6 +16,9 @@ import
|
|||||||
../../range_desc,
|
../../range_desc,
|
||||||
"."/[hexary_desc, hexary_error, snapdb_desc, snapdb_persistent]
|
"."/[hexary_desc, hexary_error, snapdb_desc, snapdb_persistent]
|
||||||
|
|
||||||
|
import
|
||||||
|
../../../../db/select_backend
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "snap-db"
|
topics = "snap-db"
|
||||||
|
|
||||||
@ -46,6 +49,7 @@ proc persistentContracts(
|
|||||||
): Result[void,HexaryError]
|
): Result[void,HexaryError]
|
||||||
{.gcsafe, raises: [OSError,IOError,KeyError].} =
|
{.gcsafe, raises: [OSError,IOError,KeyError].} =
|
||||||
## Store contract codes onto permanent database
|
## Store contract codes onto permanent database
|
||||||
|
when dbBackend == rocksdb:
|
||||||
if ps.rockDb.isNil:
|
if ps.rockDb.isNil:
|
||||||
let rc = data.persistentContractPut ps.kvDb
|
let rc = data.persistentContractPut ps.kvDb
|
||||||
if rc.isErr:
|
if rc.isErr:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# nimbus-eth1
|
# nimbus-eth1
|
||||||
# Copyright (c) 2021 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -35,6 +35,8 @@ type
|
|||||||
## Global, re-usable descriptor
|
## Global, re-usable descriptor
|
||||||
keyMap: Table[RepairKey,uint] ## For debugging only (will go away)
|
keyMap: Table[RepairKey,uint] ## For debugging only (will go away)
|
||||||
db: CoreDbRef ## General database
|
db: CoreDbRef ## General database
|
||||||
|
# Allow hive sim to compile with dbBackend == none
|
||||||
|
when dbBackend == rocksdb:
|
||||||
rocky: RocksStoreRef ## Set if rocksdb is available
|
rocky: RocksStoreRef ## Set if rocksdb is available
|
||||||
|
|
||||||
SnapDbBaseRef* = ref object of RootRef
|
SnapDbBaseRef* = ref object of RootRef
|
||||||
@ -69,6 +71,7 @@ proc keyPp(a: RepairKey; pv: SnapDbRef): string =
|
|||||||
# Private helper
|
# Private helper
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
when dbBackend == rocksdb:
|
||||||
proc clearRockyCacheFile(rocky: RocksStoreRef): bool =
|
proc clearRockyCacheFile(rocky: RocksStoreRef): bool =
|
||||||
if not rocky.isNil:
|
if not rocky.isNil:
|
||||||
# A cache file might hang about from a previous crash
|
# A cache file might hang about from a previous crash
|
||||||
@ -87,6 +90,7 @@ proc init*(
|
|||||||
db: CoreDbRef
|
db: CoreDbRef
|
||||||
): T =
|
): T =
|
||||||
## Main object constructor
|
## Main object constructor
|
||||||
|
when dbBackend == rocksdb:
|
||||||
T(db: db, rocky: db.backend.toRocksStoreRef)
|
T(db: db, rocky: db.backend.toRocksStoreRef)
|
||||||
|
|
||||||
proc init*(
|
proc init*(
|
||||||
@ -134,6 +138,7 @@ proc hexaDb*(ps: SnapDbBaseRef): HexaryTreeDbRef =
|
|||||||
## Getter, low level access to underlying session DB
|
## Getter, low level access to underlying session DB
|
||||||
ps.xDb
|
ps.xDb
|
||||||
|
|
||||||
|
when dbBackend == rocksdb:
|
||||||
proc rockDb*(ps: SnapDbBaseRef): RocksStoreRef =
|
proc rockDb*(ps: SnapDbBaseRef): RocksStoreRef =
|
||||||
## Getter, low level access to underlying persistent rock DB interface
|
## Getter, low level access to underlying persistent rock DB interface
|
||||||
ps.base.rocky
|
ps.base.rocky
|
||||||
@ -193,10 +198,12 @@ template toOpenArray*(k: ByteArray33): openArray[byte] =
|
|||||||
|
|
||||||
proc dbBackendRocksDb*(pv: SnapDbRef): bool =
|
proc dbBackendRocksDb*(pv: SnapDbRef): bool =
|
||||||
## Returns `true` if rocksdb features are available
|
## Returns `true` if rocksdb features are available
|
||||||
|
when dbBackend == rocksdb:
|
||||||
not pv.rocky.isNil
|
not pv.rocky.isNil
|
||||||
|
|
||||||
proc dbBackendRocksDb*(ps: SnapDbBaseRef): bool =
|
proc dbBackendRocksDb*(ps: SnapDbBaseRef): bool =
|
||||||
## Returns `true` if rocksdb features are available
|
## Returns `true` if rocksdb features are available
|
||||||
|
when dbBackend == rocksdb:
|
||||||
not ps.base.rocky.isNil
|
not ps.base.rocky.isNil
|
||||||
|
|
||||||
proc mergeProofs*(
|
proc mergeProofs*(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# nimbus-eth1
|
# nimbus-eth1
|
||||||
# Copyright (c) 2021 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -21,6 +21,9 @@ import
|
|||||||
hexary_inspect, hexary_interpolate, hexary_paths, snapdb_desc,
|
hexary_inspect, hexary_interpolate, hexary_paths, snapdb_desc,
|
||||||
snapdb_persistent]
|
snapdb_persistent]
|
||||||
|
|
||||||
|
import
|
||||||
|
../../../../db/select_backend
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "snap-db"
|
topics = "snap-db"
|
||||||
|
|
||||||
@ -60,6 +63,7 @@ proc persistentStorageSlots(
|
|||||||
): Result[void,HexaryError]
|
): Result[void,HexaryError]
|
||||||
{.gcsafe, raises: [OSError,IOError,KeyError].} =
|
{.gcsafe, raises: [OSError,IOError,KeyError].} =
|
||||||
## Store accounts trie table on databse
|
## Store accounts trie table on databse
|
||||||
|
when dbBackend == rocksdb:
|
||||||
if ps.rockDb.isNil:
|
if ps.rockDb.isNil:
|
||||||
let rc = db.persistentStorageSlotsPut(ps.kvDb)
|
let rc = db.persistentStorageSlotsPut(ps.kvDb)
|
||||||
if rc.isErr: return rc
|
if rc.isErr: return rc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user