Skip to content

Commit

Permalink
fix(p2p): restore dropped pair logic
Browse files Browse the repository at this point in the history
This restores logic to detect when an updated node state removes a
trading pair and fire an event. This logic was inadvertently removed
as part of #756.
  • Loading branch information
sangaman committed Feb 22, 2019
1 parent f69f931 commit 907ee16
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/p2p/Peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,17 @@ class Peer extends EventEmitter {
const nodeStateUpdate = packet.body!;
this.logger.verbose(`received node state update packet from ${this.label}: ${JSON.stringify(nodeStateUpdate)}`);

this.nodeState = { ...this.nodeState, ...nodeStateUpdate as NodeState };
const prevNodeState = this.nodeState;
if (prevNodeState) {
prevNodeState.pairs.forEach((pairId) => {
if (!nodeStateUpdate.pairs || !nodeStateUpdate.pairs.includes(pairId)) {
// a trading pair was in the old handshake state but not in the updated one
this.emit('pairDropped', pairId);
}
});
}

this.nodeState = { ...prevNodeState, ...nodeStateUpdate as NodeState };
this.emit('nodeStateUpdate');
}

Expand Down

0 comments on commit 907ee16

Please sign in to comment.