From 60a9e556f89f8f295153ac76f0ae7859eb110457 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 23 May 2014 23:26:47 -0500 Subject: [PATCH] framer: frame regular blocks with transactions correctly. --- lib/bcoin/protocol/framer.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/bcoin/protocol/framer.js b/lib/bcoin/protocol/framer.js index d75b80c0..1f9ca4ff 100644 --- a/lib/bcoin/protocol/framer.js +++ b/lib/bcoin/protocol/framer.js @@ -303,11 +303,11 @@ Framer.block = function _block(block, type) { assert.equal(off, 76); off += writeU32(p, block.nonce, off); - // txn_count (spec says this is a varint for some reason) assert.equal(off, 80); - off += writeU32(p, block.totalTX, off); if (type === 'merkleblock') { + // txn_count + off += writeU32(p, block.totalTX, off); // hash count assert.equal(off, 84); off += varint(p, block.hashes.length, off); @@ -323,6 +323,15 @@ Framer.block = function _block(block, type) { block.flags.forEach(function(flag) { p[off++] = flag; }); + } else if (type === 'block') { + // txn_count + off += varint(p, block.totalTX, off); + // txs + block.txs.forEach(function(tx) { + tx._raw.forEach(function(ch) { + p[off++] = ch; + }); + }); } return p;