fixes and cleanup.

This commit is contained in:
Christopher Jeffrey 2016-07-18 02:02:17 -07:00
parent 34ecf9b318
commit 2feef87331
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 19 additions and 11 deletions

View File

@ -1236,7 +1236,7 @@ Chain.prototype.setBestChain = function setBestChain(entry, block, prev, callbac
// A higher fork has arrived.
// Time to reorganize the chain.
self.logger.warning('WARNING: Reorganizing chain.');
this.logger.warning('WARNING: Reorganizing chain.');
return this.reorganize(entry, block, done);
};

View File

@ -848,7 +848,7 @@ ChainDB.prototype.connectBlock = function connectBlock(block, view, batch, callb
for (i = 0; i < block.txs.length; i++) {
tx = block.txs[i];
hash = tx.hash('hex');
hash = tx.hash();
if (this.options.indexTX) {
batch.put(layout.t(hash), tx.toExtended());

View File

@ -48,20 +48,30 @@ function Coins(options) {
*/
Coins.prototype.fromOptions = function fromOptions(options) {
if (options.version != null)
if (options.version != null) {
assert(utils.isNumber(options.version));
this.version = options.version;
}
if (options.hash)
if (options.hash) {
assert(typeof options.hash === 'string');
this.hash = options.hash;
}
if (options.height != null)
if (options.height != null) {
assert(utils.isNumber(options.height));
this.height = options.height;
}
if (options.coinbase != null)
if (options.coinbase != null) {
assert(typeof options.coinbase === 'boolean');
this.coinbase = options.coinbase;
}
if (options.outputs)
if (options.outputs) {
assert(Array.isArray(options.outputs));
this.outputs = options.outputs;
}
return this;
};

View File

@ -51,8 +51,6 @@ Outpoint.prototype.fromOptions = function fromOptions(options) {
*/
Outpoint.fromOptions = function fromOptions(options) {
if (options instanceof Outpoint)
return options;
return new Outpoint().fromOptions(options);
};
@ -63,7 +61,7 @@ Outpoint.fromOptions = function fromOptions(options) {
*/
Outpoint.prototype.isNull = function isNull() {
return this.hash === constants.NULL_HASH && this.index === 0xffffffff;
return this.index === 0xffffffff && this.hash === constants.NULL_HASH;
};
/**
@ -176,7 +174,7 @@ Outpoint.fromTX = function fromTX(tx, index) {
*/
Outpoint.prototype.inspect = function inspect() {
return '<Outpoint: ' + this.hash + '/' + this.index + '>';
return '<Outpoint: ' + utils.revHex(this.hash) + '/' + this.index + '>';
};
/**