make sure to poll quicker if we get >95 messages on one polling

pull/1978/head
Audric Ackermann 4 years ago
parent ae8688bf2a
commit 760b99587a
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -232,12 +232,19 @@ export class SwarmPolling {
window?.log?.info( window?.log?.info(
`Polled for group(${ed25519Str(pubkey.key)}):, got ${messages.length} messages back.` `Polled for group(${ed25519Str(pubkey.key)}):, got ${messages.length} messages back.`
); );
let lastPolledTimestamp = Date.now();
if (messages.length >= 95) {
// if we get 95 messages or more back, it means there are probably more than this
// so make sure to retry the polling in the next 5sec by marking the last polled timestamp way before that it is really
// this is a kind of hack
lastPolledTimestamp = Date.now() - SWARM_POLLING_TIMEOUT.INACTIVE - 5 * 1000;
}
// update the last fetched timestamp // update the last fetched timestamp
this.groupPolling = this.groupPolling.map(group => { this.groupPolling = this.groupPolling.map(group => {
if (PubKey.isEqual(pubkey, group.pubkey)) { if (PubKey.isEqual(pubkey, group.pubkey)) {
return { return {
...group, ...group,
lastPolledTimestamp: Date.now(), lastPolledTimestamp,
}; };
} }
return group; return group;

Loading…
Cancel
Save