Result rocks (#225)

* rocksdb: update
This commit is contained in:
Jacek Sieka 2020-04-18 07:21:13 +02:00 committed by GitHub
parent 7c709551a5
commit e9b25b5309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -4,7 +4,7 @@ description = "Ethereum Common library"
license = "MIT"
skipDirs = @["tests"]
requires "nim >= 0.19.0",
requires "nim >= 1.2.0",
"nimcrypto",
"stint",
"secp256k1",

View File

@ -13,7 +13,7 @@ const maxOpenFiles = 512
proc get*(db: ChainDB, key: openarray[byte]): seq[byte] =
let s = db.store.getBytes(key)
if s.ok:
if s.isOk:
result = s.value
traceGet key, result
elif s.error.len == 0:
@ -24,17 +24,17 @@ proc get*(db: ChainDB, key: openarray[byte]): seq[byte] =
proc put*(db: ChainDB, key, value: openarray[byte]) =
tracePut key, value
let s = db.store.put(key, value)
if not s.ok: raiseKeyWriteError(key)
if not s.isOk: raiseKeyWriteError(key)
proc contains*(db: ChainDB, key: openarray[byte]): bool =
let s = db.store.contains(key)
if not s.ok: raiseKeySearchError(key)
if not s.isOk: raiseKeySearchError(key)
return s.value
proc del*(db: ChainDB, key: openarray[byte]) =
traceDel key
let s = db.store.del(key)
if not s.ok: raiseKeyDeletionError(key)
if not s.isOk: raiseKeyDeletionError(key)
proc close*(db: ChainDB) =
db.store.close
@ -50,7 +50,7 @@ proc newChainDB*(basePath: string, readOnly = false): ChainDB =
let s = result.store.init(dataDir, backupsDir, readOnly,
maxOpenFiles = maxOpenFiles)
if not s.ok: raiseStorageInitError()
if not s.isOk: raiseStorageInitError()
if not readOnly:
put(result, emptyRlpHash.data, emptyRlp)