From aa0109e29bd99fb08eae60a43fe4fe7a0a5e0fd7 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 3 May 2022 11:00:38 +1000 Subject: [PATCH] Try to ensure that no two messages have same timestamp --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9978549..4af9c3f 100644 --- a/index.js +++ b/index.js @@ -92,7 +92,9 @@ export default function runAll(nodes) { `sent via ${hostnames[i]} - ${id}`, contentTopic ); - return waku.relay.send(msg); + // Wait 1 ms to be sure that no two messages have the same timestamp. + // Timestamp are in milliseconds in js-waku. + return delay(1).then(() => waku.relay.send(msg)); }); await Promise.all(relayPromises); @@ -168,7 +170,9 @@ export default function runAll(nodes) { `sent via ${hostnames[i]} - ${id}`, contentTopic ); - return waku.lightPush.push(msg); + // Wait 1 ms to be sure that no two messages have the same timestamp. + // Timestamp are in milliseconds in js-waku. + return delay(1).then(() => waku.lightPush.push(msg)); }); await Promise.all(relayPromises); @@ -226,7 +230,9 @@ export default function runAll(nodes) { `sent via ${nodes[i]} - ${id}`, contentTopic ); - return waku.lightPush.push(msg); + // Wait 1 ms to be sure that no two messages have the same timestamp. + // Timestamp are in milliseconds in js-waku. + return delay(1).then(() => waku.lightPush.push(msg)); }); await Promise.all(pushPromises);