Simplified the addContactP2pDetails logic cause it was silly

pull/161/head
Beaudan 7 years ago
parent a40a3d164f
commit 1ce63add68

@ -16,34 +16,16 @@ class LokiP2pAPI extends EventEmitter {
? 60 * 1000 // 1 minute ? 60 * 1000 // 1 minute
: 2 * 60 * 1000; // 2 minutes : 2 * 60 * 1000; // 2 minutes
if (!this.contactP2pDetails[pubKey]) { if (this.contactP2pDetails[pubKey] && this.contactP2pDetails[pubKey].pingTimer) {
// If this is the first time we are getting this contacts details clearTimeout(this.contactP2pDetails[pubKey].pingTimer);
// then we try to ping them straight away
this.contactP2pDetails[pubKey] = {
address,
port,
timerDuration,
isOnline: false,
pingTimer: null,
};
this.pingContact(pubKey);
return;
} }
this.contactP2pDetails[pubKey] = {
clearTimeout(this.contactP2pDetails[pubKey].pingTimer); address,
if ( port,
this.contactP2pDetails[pubKey].address !== address || timerDuration,
this.contactP2pDetails[pubKey].port !== port isOnline: false,
) { pingTimer: null,
// If this contact has changed their details };
// then we try to ping them straight away
this.contactP2pDetails[pubKey].address = address;
this.contactP2pDetails[pubKey].port = port;
this.contactP2pDetails[pubKey].isOnline = false;
this.pingContact(pubKey);
return;
}
if (resetTimer) { if (resetTimer) {
// If this contact is simply sharing the same details with us // If this contact is simply sharing the same details with us
// then we just reset our timer // then we just reset our timer

Loading…
Cancel
Save