tx/block: remove hashAsync.

This commit is contained in:
Christopher Jeffrey 2016-11-22 10:28:54 -08:00
parent 7f5e0cb493
commit 0e40eb6491
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 0 additions and 87 deletions

View File

@ -1318,8 +1318,6 @@ Chain.prototype._add = co(function* add(block) {
'error parsing message',
100);
}
if (util.isBrowser)
yield block.cacheHashes();
}
// Update the block height early

View File

@ -917,9 +917,6 @@ Pool.prototype._handleBlock = co(function* _handleBlock(block, peer) {
// Fulfill the load request.
requested = this.fulfill(block);
if (util.isBrowser)
yield block.hashAsync();
// Someone is sending us blocks without
// us requesting them.
if (!requested) {
@ -1333,9 +1330,6 @@ Pool.prototype.hasReject = function hasReject(hash) {
Pool.prototype._handleTX = co(function* _handleTX(tx, peer) {
var i, requested, missing;
if (util.isBrowser)
yield tx.hashAsync();
// Fulfill the load request.
requested = this.fulfill(tx);

View File

@ -10,7 +10,6 @@
var assert = require('assert');
var constants = require('../protocol/constants');
var util = require('../utils/util');
var co = require('../utils/co');
var crypto = require('../crypto/crypto');
var btcutils = require('../btc/utils');
var VerifyResult = require('../btc/errors').VerifyResult;
@ -161,54 +160,6 @@ AbstractBlock.prototype.hash = function hash(enc) {
return hash;
};
/**
* Hash the block headers (async).
* @param {String?} enc - Can be `'hex'` or `null`.
* @returns {Hash|Buffer} hash
*/
AbstractBlock.prototype.hashAsync = co(function* hashAsync(enc) {
var hash = this._hash;
var hex;
if (!hash) {
hash = yield crypto.hash256Async(this.abbr());
if (!this.mutable)
this._hash = hash;
}
if (enc === 'hex') {
hex = this._hhash;
if (!hex) {
hex = hash.toString('hex');
if (!this.mutable)
this._hhash = hex;
}
hash = hex;
}
return hash;
});
/**
* Cache hashes.
* @private
*/
AbstractBlock.prototype.cacheHashes = co(function* cacheHashes() {
var i, tx;
yield this.hashAsync();
if (!this.txs)
return;
for (i = 0; i < this.txs.length; i++) {
tx = this.txs[i];
yield tx.hashAsync();
}
});
/**
* Serialize the block headers.
* @returns {Buffer}

View File

@ -9,7 +9,6 @@
var assert = require('assert');
var util = require('../utils/util');
var co = require('../utils/co');
var crypto = require('../crypto/crypto');
var btcutils = require('../btc/utils');
var Amount = require('../btc/amount');
@ -242,35 +241,6 @@ TX.prototype.hash = function _hash(enc) {
return hash;
};
/**
* Hash the transaction with the non-witness serialization (async).
* @param {String?} enc - Can be `'hex'` or `null`.
* @returns {Hash|Buffer} hash
*/
TX.prototype.hashAsync = co(function* _hashAsync(enc) {
var hash = this._hash;
var hex;
if (!hash) {
hash = yield crypto.hash256Async(this.toNormal());
if (!this.mutable)
this._hash = hash;
}
if (enc === 'hex') {
hex = this._hhash;
if (!hex) {
hex = hash.toString('hex');
if (!this.mutable)
this._hhash = hex;
}
hash = hex;
}
return hash;
});
/**
* Hash the transaction with the witness
* serialization, return the wtxid (normal