mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-15 21:47:21 +00:00
Improve performance of DbGetHandler.
This commit is contained in:
parent
29002618a6
commit
09a9951a13
@ -457,14 +457,15 @@ proc adjustRadius(
|
|||||||
proc createGetHandler*(db: ContentDB): DbGetHandler =
|
proc createGetHandler*(db: ContentDB): DbGetHandler =
|
||||||
return (
|
return (
|
||||||
proc(contentKey: ContentKeyByteList, contentId: ContentId): Opt[seq[byte]] =
|
proc(contentKey: ContentKeyByteList, contentId: ContentId): Opt[seq[byte]] =
|
||||||
var res = Opt.none(seq[byte])
|
var res: seq[byte]
|
||||||
|
|
||||||
proc onData(data: openArray[byte]) =
|
proc onData(data: openArray[byte]) =
|
||||||
res = Opt.some(@data)
|
res = @data
|
||||||
|
|
||||||
discard db.get(contentId, onData)
|
if db.get(contentId, onData):
|
||||||
|
Opt.some(res)
|
||||||
ensureMove(res)
|
else:
|
||||||
|
Opt.none(seq[byte])
|
||||||
)
|
)
|
||||||
|
|
||||||
proc createStoreHandler*(db: ContentDB, cfg: RadiusConfig): DbStoreHandler =
|
proc createStoreHandler*(db: ContentDB, cfg: RadiusConfig): DbStoreHandler =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user