mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-26 23:02:30 +00:00
chore(rln-db-inspector): add more logging to find zero leaf indices (#2617)
* chore(rln-db-inspector): add more logging to find zero leaf indices * fix: assumeEmptyAfter var
This commit is contained in:
parent
9c9883a630
commit
40752b1e89
@ -38,4 +38,29 @@ proc doInspectRlnDb*(conf: WakuNodeConf) =
|
||||
contractAddress = metadata.contractAddress,
|
||||
validRoots = metadata.validRoots.mapIt(it.inHex())
|
||||
|
||||
var index: uint = 0
|
||||
var hits: uint = 0
|
||||
var zeroLeafIndices: seq[uint] = @[]
|
||||
var assumeEmptyAfter: uint = 10
|
||||
while true:
|
||||
let leaf = rlnInstance.getMember(index).valueOr:
|
||||
error "failure while getting RLN leaf", error
|
||||
quit(1)
|
||||
|
||||
if leaf.inHex() == "0000000000000000000000000000000000000000000000000000000000000000":
|
||||
zeroLeafIndices.add(index)
|
||||
hits = hits + 1
|
||||
else:
|
||||
hits = 0
|
||||
|
||||
if hits > assumeEmptyAfter:
|
||||
info "reached end of RLN tree", index = index - assumeEmptyAfter
|
||||
# remove zeroLeafIndices that are not at the end of the tree
|
||||
zeroLeafIndices = zeroLeafIndices.filterIt(it < index - assumeEmptyAfter)
|
||||
break
|
||||
|
||||
index = index + 1
|
||||
|
||||
info "zero leaf indices", zeroLeafIndices
|
||||
|
||||
quit(0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user