Skip to content

Commit 907ee16

Browse files
committed
fix(p2p): restore dropped pair logic
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.
1 parent f69f931 commit 907ee16

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/p2p/Peer.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,17 @@ class Peer extends EventEmitter {
801801
const nodeStateUpdate = packet.body!;
802802
this.logger.verbose(`received node state update packet from ${this.label}: ${JSON.stringify(nodeStateUpdate)}`);
803803

804-
this.nodeState = { ...this.nodeState, ...nodeStateUpdate as NodeState };
804+
const prevNodeState = this.nodeState;
805+
if (prevNodeState) {
806+
prevNodeState.pairs.forEach((pairId) => {
807+
if (!nodeStateUpdate.pairs || !nodeStateUpdate.pairs.includes(pairId)) {
808+
// a trading pair was in the old handshake state but not in the updated one
809+
this.emit('pairDropped', pairId);
810+
}
811+
});
812+
}
813+
814+
this.nodeState = { ...prevNodeState, ...nodeStateUpdate as NodeState };
805815
this.emit('nodeStateUpdate');
806816
}
807817

0 commit comments

Comments
 (0)