framer: fix block framing.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
parent
6d9c150134
commit
f3c9ebd9a5
@ -257,32 +257,41 @@ Framer.block = function _block(block, type) {
|
||||
var p = [];
|
||||
var off = 0;
|
||||
|
||||
// version
|
||||
assert.equal(off, 0);
|
||||
off += writeU32(p, constants.version, off);
|
||||
|
||||
// prev_block
|
||||
assert.equal(off, 4);
|
||||
utils.toArray(block.prevBlock, 'hex').forEach(function(ch) {
|
||||
p[off++] = ch;
|
||||
});
|
||||
|
||||
// merkle_root
|
||||
assert.equal(off, 36);
|
||||
utils.toArray(block.merkleRoot, 'hex').forEach(function(ch) {
|
||||
p[off++] = ch;
|
||||
});
|
||||
|
||||
// timestamp
|
||||
assert.equal(off, 68);
|
||||
off += writeU32(p, block.ts, off);
|
||||
|
||||
// bits
|
||||
assert.equal(off, 72);
|
||||
off += writeU32(p, block.bits, off);
|
||||
|
||||
// nonce
|
||||
assert.equal(off, 76);
|
||||
off += writeU32(p, block.nonce, off);
|
||||
|
||||
// txn_count
|
||||
off += varint(p, block.totalTX, 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') {
|
||||
// hash count
|
||||
assert.equal(off, 84);
|
||||
off += varint(p, block.hashes.length, off);
|
||||
// hashes
|
||||
block.hashes.forEach(function(hash) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user