Skip to content

Commit

Permalink
fix(p2p): don't send empty GetOrders packet
Browse files Browse the repository at this point in the history
This prevents sending a GetOrders packet on connection when we don't
have any active trading pairs to request. A GetOrders packet without
any pairs specified is an invalid packet and results in a penalty.
  • Loading branch information
sangaman committed Dec 24, 2018
1 parent 32e3263 commit fbacd8b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/p2p/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,11 @@ class Pool extends EventEmitter {
this.peers.set(peer.nodePubKey, peer);
peer.active = true;

// request peer's orders
peer.sendPacket(new packets.GetOrdersPacket({ pairIds: this.handshakeData.pairs }));
if (this.handshakeData.pairs.length > 0) {
// request peer's orders
peer.sendPacket(new packets.GetOrdersPacket({ pairIds: this.handshakeData.pairs }));
}

if (this.config.discover) {
// request peer's known nodes only if p2p.discover option is true
peer.sendPacket(new packets.GetNodesPacket());
Expand Down

0 comments on commit fbacd8b

Please sign in to comment.