From 1096cd0bd94f0c812103ebb351df6e61590db9ce Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 17 Sep 2016 18:25:45 -0700 Subject: [PATCH] peer: fix checksum optimization for spv serving. --- lib/net/peer.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/net/peer.js b/lib/net/peer.js index 795ec471..1b6a4254 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -746,14 +746,18 @@ Peer.prototype.write = function write(data) { */ Peer.prototype.send = function send(packet) { - var checksum; + var tx, checksum; // Used cached hashes as the // packet checksum for speed. if (packet.type === packetTypes.TX) { - checksum = packet.witness - ? packet.tx.witnessHash() - : packet.tx.hash(); + tx = packet.tx; + if (packet.witness) { + if (!tx.isCoinbase()) + checksum = tx.witnessHash() + } else { + checksum = tx.hash(); + } } this.write(this.framer.packet(packet.cmd, packet.toRaw(), checksum));