diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index 8395b17b..26b50562 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -599,20 +599,13 @@ Block.prototype.toRaw = function toRaw(enc) { * Parse a serialized block. * @param {Buffer} data * @param {String?} enc - Encoding, can be `'hex'` or null. - * @param {String?} type - Can be `'block'`, `'merkleblock'`, or `'headers'`. * @returns {Object} A "naked" block object. */ -Block.parseRaw = function parseRaw(data, enc, type) { +Block.parseRaw = function parseRaw(data, enc) { if (enc === 'hex') data = new Buffer(data, 'hex'); - if (type === 'merkleblock') - return bcoin.merkleblock.parseRaw(data); - - if (type === 'headers') - return bcoin.headers.parseRaw(data); - return bcoin.protocol.parser.parseBlock(data); }; @@ -620,17 +613,10 @@ Block.parseRaw = function parseRaw(data, enc, type) { * Instantiate a block from a serialized Buffer. * @param {Buffer} data * @param {String?} enc - Encoding, can be `'hex'` or null. - * @param {String?} type - Can be `'block'`, `'merkleblock'`, or `'headers'`. * @returns {Block} */ -Block.fromRaw = function fromRaw(data, enc, type) { - if (type === 'merkleblock') - return bcoin.merkleblock.fromRaw(data, enc); - - if (type === 'headers') - return bcoin.headers.fromRaw(data, enc); - +Block.fromRaw = function fromRaw(data, enc) { return new Block(Block.parseRaw(data, enc)); }; diff --git a/lib/bcoin/bloom.js b/lib/bcoin/bloom.js index dba45694..f05865b7 100644 --- a/lib/bcoin/bloom.js +++ b/lib/bcoin/bloom.js @@ -12,7 +12,7 @@ var assert = utils.assert; * Bloom Filter * @exports Bloom * @constructor - * @param {Number|Bufer} size - Filter size in bytes, or filter itself. + * @param {Number|Bufer} size - Filter size in bits, or filter itself. * @param {Number} n - Number of hash functions. * @param {Number} tweak - Seed value. * @property {Buffer} filter @@ -74,7 +74,7 @@ Bloom.prototype.add = function add(val, enc) { for (i = 0; i < this.n; i++) { bit = this.hash(val, i); pos = 1 << (bit & 0x1f); - shift = bit >> 5; + shift = bit >>> 5; shift *= 4; utils.writeU32(this.filter, utils.readU32(this.filter, shift) | pos, shift); @@ -97,7 +97,7 @@ Bloom.prototype.test = function test(val, enc) { for (i = 0; i < this.n; i++) { bit = this.hash(val, i); pos = 1 << (bit & 0x1f); - shift = bit >> 5; + shift = bit >>> 5; shift *= 4; if ((utils.readU32(this.filter, shift) & pos) === 0) diff --git a/lib/bcoin/chaindb.js b/lib/bcoin/chaindb.js index ab551614..c1cc4754 100644 --- a/lib/bcoin/chaindb.js +++ b/lib/bcoin/chaindb.js @@ -145,7 +145,7 @@ ChainDB.prototype._init = function _init() { }, null); block = bcoin.block.fromRaw(network.genesisBlock, 'hex'); - block.height = 0; + block.setHeight(0); self.save(genesis, block, true, finish); });