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" license = "MIT"
skipDirs = @["tests"] skipDirs = @["tests"]
requires "nim >= 0.19.0", requires "nim >= 1.2.0",
"nimcrypto", "nimcrypto",
"stint", "stint",
"secp256k1", "secp256k1",

View File

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