set height on genesis block.

This commit is contained in:
Christopher Jeffrey 2016-05-04 17:16:19 -07:00
parent aefe60b6d4
commit 477c4f5dbb
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 6 additions and 20 deletions

View File

@ -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));
};

View File

@ -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)

View File

@ -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);
});