Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added check for peer's pairs on order invalidation #1864

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/p2p/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,9 @@ class Pool extends EventEmitter {
const orderInvalidationPacket = new packets.OrderInvalidationPacket({ id, pairId, quantity });
this.peers.forEach(async (peer) => {
if (!nodeToExclude || peer.nodePubKey !== nodeToExclude) {
await peer.sendPacket(orderInvalidationPacket);
if (peer.isPairActive(pairId)) {
await peer.sendPacket(orderInvalidationPacket);
}
}
});

Expand Down Expand Up @@ -786,8 +788,12 @@ class Pool extends EventEmitter {
}
case PacketType.OrderInvalidation: {
const orderInvalidation = (packet as packets.OrderInvalidationPacket).body!;
this.logger.trace(`received order invalidation from ${peer.label}: ${JSON.stringify(orderInvalidation)}`);
this.emit('packet.orderInvalidation', orderInvalidation, peer.nodePubKey as string);
if (peer.isPairActive(orderInvalidation.pairId)) {
this.logger.trace(`received order invalidation from ${peer.label}: ${JSON.stringify(orderInvalidation)}`);
this.emit('packet.orderInvalidation', orderInvalidation, peer.nodePubKey as string);
} else {
this.logger.trace(`received order invalidation for inactive pair from ${peer.label}: ${JSON.stringify(orderInvalidation)}`);
}
break;
}
case PacketType.GetOrders: {
Expand Down