mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 16:33:08 +00:00
chore: asyncSpwan trackRoots
This commit is contained in:
parent
e141390d23
commit
6f0cbae03a
2
Makefile
2
Makefile
@ -165,7 +165,7 @@ nimbus-build-system-nimble-dir:
|
||||
.PHONY: librln
|
||||
|
||||
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
||||
LIBRLN_VERSION := v0.5.1
|
||||
LIBRLN_VERSION := v0.7.0
|
||||
|
||||
ifeq ($(detected_OS),Windows)
|
||||
LIBRLN_FILE := rln.lib
|
||||
|
||||
@ -188,39 +188,39 @@ proc updateRoots*(g: OnchainGroupManager): Future[bool] {.async.} =
|
||||
discard g.validRoots.popFirst()
|
||||
|
||||
g.validRoots.addLast(merkleRoot)
|
||||
debug "~~~~~~~~~~~~~ Detected new Merkle root ~~~~~~~~~~~~~~~~",
|
||||
debug "------ Detected new Merkle root -------",
|
||||
root = merkleRoot.toHex, totalRoots = g.validRoots.len
|
||||
return true
|
||||
else:
|
||||
debug "~~~~~~~~~~~~~ No new Merkle root ~~~~~~~~~~~~~~~~",
|
||||
debug "------ No new Merkle root ------",
|
||||
root = merkleRoot.toHex, totalRoots = g.validRoots.len
|
||||
|
||||
return false
|
||||
|
||||
# proc trackRootChanges*(g: OnchainGroupManager): Future[void] {.async.} =
|
||||
# ## Continuously track changes to the Merkle root
|
||||
# initializedGuard(g)
|
||||
#
|
||||
# let ethRpc = g.ethRpc.get()
|
||||
# let wakuRlnContract = g.wakuRlnContract.get()
|
||||
#
|
||||
# # Set up the polling interval - more frequent to catch roots
|
||||
# const rpcDelay = 5.seconds
|
||||
#
|
||||
# info "Starting to track Merkle root changes"
|
||||
#
|
||||
# while true:
|
||||
# debug "starting to update roots"
|
||||
# let rootUpdated = await g.updateRoots()
|
||||
#
|
||||
# if rootUpdated:
|
||||
# let proofResult = await g.fetchMerkleProofElements()
|
||||
# if proofResult.isErr():
|
||||
# error "Failed to fetch Merkle proof", error = proofResult.error
|
||||
# g.merkleProofCache = proofResult.get()
|
||||
#
|
||||
# debug "sleeping for 5 seconds"
|
||||
# await sleepAsync(rpcDelay)
|
||||
proc trackRootChanges*(g: OnchainGroupManager) {.async.} =
|
||||
## Continuously track changes to the Merkle root
|
||||
initializedGuard(g)
|
||||
|
||||
let ethRpc = g.ethRpc.get()
|
||||
let wakuRlnContract = g.wakuRlnContract.get()
|
||||
|
||||
# Set up the polling interval - more frequent to catch roots
|
||||
const rpcDelay = 5.seconds
|
||||
|
||||
info "------ Starting to track Merkle root changes ------",
|
||||
|
||||
while true:
|
||||
debug "------ starting to update roots ------",
|
||||
let rootUpdated = await g.updateRoots()
|
||||
|
||||
if rootUpdated:
|
||||
let proofResult = await g.fetchMerkleProofElements()
|
||||
if proofResult.isErr():
|
||||
error "Failed to fetch Merkle proof", error = proofResult.error
|
||||
g.merkleProofCache = proofResult.get()
|
||||
|
||||
debug "sleeping for 5 seconds"
|
||||
await sleepAsync(rpcDelay)
|
||||
|
||||
method atomicBatch*(
|
||||
g: OnchainGroupManager,
|
||||
|
||||
@ -463,6 +463,7 @@ proc mount(
|
||||
membershipIndex: conf.rlnRelayCredIndex,
|
||||
onFatalErrorAction: conf.onFatalErrorAction,
|
||||
)
|
||||
asyncSpawn trackRootChanges(cast[OnchainGroupManager](groupManager))
|
||||
|
||||
# Initialize the groupManager
|
||||
(await groupManager.init()).isOkOr:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user