Jordan Hrycaj dda049cd43
Simple stupid key-value table companion for Aristo DB (#1746)
why:
  Additional tables needed for the `CoreDB` object with separate
  key-value table and MPT.

details:
+ Stripped down copy of Aristo DB to have a similar look'n feel. Otherwise
  it is just a posh way for accessing `Table` objects or `RocksDB` data.
+ No unit tests yet, will be tested on the go.
2023-09-12 19:44:45 +01:00

44 lines
1.2 KiB
Nim

# nimbus-eth1
# Copyright (c) 2021 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed
# except according to those terms.
## Rocks DB fetch data record
## ==========================
{.push raises: [].}
import
eth/common,
rocksdb,
results,
"../.."/[kvt_constants, kvt_desc],
./rdb_desc
# ------------------------------------------------------------------------------
# Public functions
# ------------------------------------------------------------------------------
proc get*(
rdb: RdbInst;
key: openArray[byte],
): Result[Blob,(KvtError,string)] =
var res: Blob
let onData: DataProc = proc(data: openArray[byte]) =
res = @data
let rc = rdb.store.get(key, onData)
if rc.isErr:
return err((RdbBeDriverGetError,rc.error))
if not rc.value:
res = EmptyBlob
ok res
# ------------------------------------------------------------------------------
# End
# ------------------------------------------------------------------------------