Jordan Hrycaj 8e00143313
Aristo db code massage n cosmetics (#1745)
* Rewrite remaining `AristoError` return code into `Result[void,AristoError]`

why:
  Better code maintenance

* Update import sections

* Update Aristo DB paths

why:
 More systematic so directory can be shared with other DB types

* More cosmetcs

* Update unit tests runners

why:
  Proper handling of persistent and mem-only DB. The latter can be
  consistently triggered by an empty DB path.
2023-09-12 19:45:12 +01:00

44 lines
1.3 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,
"../.."/[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
# ------------------------------------------------------------------------------