mirror of https://github.com/waku-org/nwaku.git
fix: add more logs, stagger intervals & set prune offset to 10% for waku sync (#3142)
This commit is contained in:
parent
80c7581ab1
commit
a386880be9
|
@ -35,16 +35,4 @@ template nanosecondTime*(collector: Gauge, body: untyped) =
|
|||
metrics.set(collector, nowInUnixFloat() - start)
|
||||
else:
|
||||
body
|
||||
|
||||
# Unused yet. Kept for future use in Waku Sync.
|
||||
#[ proc timestampInSeconds*(time: Timestamp): Timestamp =
|
||||
let timeStr = $time
|
||||
var timestamp: Timestamp = time
|
||||
|
||||
if timeStr.len() > 16:
|
||||
timestamp = Timestamp(time div Timestamp(1_000_000_000))
|
||||
elif timeStr.len() < 16 and timeStr.len() > 13:
|
||||
timestamp = Timestamp(time div Timestamp(1_000_000))
|
||||
elif timeStr.len() > 10:
|
||||
timestamp = Timestamp(time div Timestamp(1000))
|
||||
return timestamp ]#
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ proc messageIngress*(
|
|||
trace "inserting message into waku sync storage ",
|
||||
msg_hash = msgHash.to0xHex(), timestamp = msg.timestamp
|
||||
|
||||
if self.storage.insert(msg.timestamp, msgHash).isErr():
|
||||
error "failed to insert message ", msg_hash = msgHash.to0xHex()
|
||||
self.storage.insert(msg.timestamp, msgHash).isOkOr:
|
||||
error "failed to insert message ", msg_hash = msgHash.to0xHex(), error = error
|
||||
|
||||
proc calculateRange(
|
||||
jitter: Duration = 20.seconds, syncRange: Duration = 1.hours
|
||||
|
@ -130,6 +130,9 @@ proc request(
|
|||
debug "sync session ended gracefully",
|
||||
client = self.peerManager.switch.peerInfo.peerId, server = conn.peerId
|
||||
|
||||
trace "hashes to sync",
|
||||
client = self.peerManager.switch.peerInfo.peerId, msg_hashes = $hashes
|
||||
|
||||
return ok(hashes)
|
||||
|
||||
continue
|
||||
|
@ -177,6 +180,9 @@ proc handleSyncSession(
|
|||
|
||||
let hashes = await completed.serverTerminate()
|
||||
|
||||
trace "hashes to sync",
|
||||
server = self.peerManager.switch.peerInfo.peerId, msg_hashes = $hashes
|
||||
|
||||
return ok(hashes)
|
||||
|
||||
sent = ?await reconciled.send()
|
||||
|
@ -364,7 +370,7 @@ proc new*(
|
|||
syncInterval: syncInterval,
|
||||
syncRange: syncRange,
|
||||
relayJitter: relayJitter,
|
||||
pruneOffset: syncInterval div 100,
|
||||
pruneOffset: syncInterval div 10, # 10% offset
|
||||
)
|
||||
|
||||
sync.initProtocolHandler()
|
||||
|
@ -400,6 +406,9 @@ proc new*(
|
|||
proc periodicSync(self: WakuSync, callback: TransferCallback) {.async.} =
|
||||
debug "periodic sync initialized", interval = $self.syncInterval
|
||||
|
||||
# to stagger the intervals
|
||||
await sleepAsync((self.syncInterval div 2))
|
||||
|
||||
while true: # infinite loop
|
||||
await sleepAsync(self.syncInterval)
|
||||
|
||||
|
|
Loading…
Reference in New Issue