2023-06-20 13:26:25 +00:00
|
|
|
# nimbus-eth1
|
2023-11-08 16:52:25 +00:00
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
2023-06-20 13:26:25 +00:00
|
|
|
# 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,
|
2023-09-12 18:45:12 +00:00
|
|
|
results,
|
2023-06-20 13:26:25 +00:00
|
|
|
"../.."/[aristo_constants, aristo_desc],
|
|
|
|
./rdb_desc
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
proc get*(
|
|
|
|
rdb: RdbInst;
|
|
|
|
key: openArray[byte],
|
|
|
|
): Result[Blob,(AristoError,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
|
|
|
|
# ------------------------------------------------------------------------------
|