From fbacd8b42485b16128cad2b1d02ee603dd8acf17 Mon Sep 17 00:00:00 2001 From: Daniel McNally Date: Thu, 20 Dec 2018 17:34:47 -0500 Subject: [PATCH] fix(p2p): don't send empty GetOrders packet 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. --- lib/p2p/Pool.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/p2p/Pool.ts b/lib/p2p/Pool.ts index 72b7a944a..c4971c447 100644 --- a/lib/p2p/Pool.ts +++ b/lib/p2p/Pool.ts @@ -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());