From 53c943ff86f41140c05c7bd4e36d8cfe42b43136 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 22 Mar 2022 01:05:26 +0100 Subject: [PATCH] keep announcing peer to not fall off the list --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 11ed204..be1ee43 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ const TOPIC = DHT.hash(Buffer.from('GRADIDO')) const POLLTIME = 20000 const SUCCESSTIME = 120000 const ERRORTIME = 240000 +const ANNOUNCETIME = 30000 const nodeRand = between(1, 99) const nodeURL = `https://test${nodeRand}.org` const nodeAPI = { @@ -39,7 +40,10 @@ const main = async () => { await server.listen() - await node.announce(TOPIC, keyPair).finished() + setInterval(async () => { + console.log('Announcing on topic:', TOPIC.toString('hex')) + await node.announce(TOPIC, keyPair).finished() + }, ANNOUNCETIME) let successfulRequests: string[] = [] let errorfulRequests: string[] = []