Skip to content

Commit

Permalink
dont add further beacons or pair requests from the same peer.
Browse files Browse the repository at this point in the history
  • Loading branch information
caedesvvv committed Oct 26, 2014
1 parent d5d300b commit 3ff27aa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/backend/channels/catchan.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ function (Bitcoin, Curve25519, Encryption, Protocol, Peer, ChannelUtils, Port) {
};

Channel.prototype.onPairMessage = function(data) {
this.peerRequests.push(data);
var found = this.peerRequests.some(function(request){return request.body.pub===data.body.pub;});
if (!found) {
this.peerRequests.push(data);
}
};

Channel.prototype.checkPairMessage = function(decoded) {
Expand Down Expand Up @@ -496,7 +499,10 @@ function (Bitcoin, Curve25519, Encryption, Protocol, Peer, ChannelUtils, Port) {
}
});
if (valid && !accepted) {
this.peerRequests.push(decoded);
var found = this.peerRequests.some(function(request){return request.body.pub===decoded.body.pub;});
if (!found) {
this.peerRequests.push(decoded);
}
}
this.triggerCallbacks('Beacon', decoded);
return decoded;
Expand Down

0 comments on commit 3ff27aa

Please sign in to comment.