refactor.
This commit is contained in:
parent
b4bfe53bfe
commit
bd3d17ef53
@ -98,7 +98,7 @@ function Peer(pool, options) {
|
||||
this.localNonce = utils.nonce();
|
||||
this.filterRate = -1;
|
||||
|
||||
this.challenge = null;
|
||||
this.challenge = utils.nonce();
|
||||
this.lastPong = 0;
|
||||
|
||||
this.banScore = 0;
|
||||
@ -130,7 +130,7 @@ function Peer(pool, options) {
|
||||
map: {}
|
||||
};
|
||||
|
||||
this.pings = {
|
||||
this.ping = {
|
||||
timer: null,
|
||||
interval: this.options.pingInterval || 30000
|
||||
};
|
||||
@ -186,13 +186,12 @@ Peer.prototype._init = function init() {
|
||||
self._error(err);
|
||||
});
|
||||
|
||||
this.challenge = utils.nonce();
|
||||
|
||||
this.pings.timer = setInterval(function() {
|
||||
this.ping.timer = setInterval(function() {
|
||||
// self.challenge = utils.nonce();
|
||||
self.write(self.framer.ping({
|
||||
nonce: self.challenge
|
||||
}));
|
||||
}, this.pings.interval);
|
||||
}, this.ping.interval);
|
||||
|
||||
this.request('verack', function(err, payload) {
|
||||
if (err) {
|
||||
@ -263,7 +262,7 @@ Peer.prototype.createSocket = function createSocket(port, host) {
|
||||
'Connecting to %s:%d (priority=%s).',
|
||||
hostname, this.priority);
|
||||
|
||||
socket.on('connect', function() {
|
||||
socket.once('connect', function() {
|
||||
bcoin.debug(
|
||||
'Connected to %s:%d (priority=%s).',
|
||||
hostname, self.priority);
|
||||
@ -368,8 +367,8 @@ Peer.prototype.destroy = function destroy() {
|
||||
this.socket = null;
|
||||
this.emit('close');
|
||||
|
||||
clearInterval(this.pings.timer);
|
||||
this.pings.timer = null;
|
||||
clearInterval(this.ping.timer);
|
||||
this.ping.timer = null;
|
||||
|
||||
Object.keys(this.requests.map).forEach(function(cmd) {
|
||||
var queue = this.requests.map[cmd];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user