chain/mempool: more aggressive asserts.
This commit is contained in:
parent
6b5cba635a
commit
7d61cda3aa
@ -1121,7 +1121,7 @@ ChainDB.prototype.getCoinsByAddress = co(function* getCoinsByAddress(addresses)
|
||||
hash = Address.getHash(address);
|
||||
|
||||
if (!hash)
|
||||
continue;
|
||||
throw new Error('Not an address.');
|
||||
|
||||
keys = yield this.db.keys({
|
||||
gte: layout.C(hash, encoding.ZERO_HASH, 0),
|
||||
@ -1132,9 +1132,8 @@ ChainDB.prototype.getCoinsByAddress = co(function* getCoinsByAddress(addresses)
|
||||
for (j = 0; j < keys.length; j++) {
|
||||
key = keys[j];
|
||||
coin = yield this.getCoin(key[0], key[1]);
|
||||
|
||||
if (coin)
|
||||
coins.push(coin);
|
||||
assert(coin);
|
||||
coins.push(coin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1160,7 +1159,7 @@ ChainDB.prototype.getHashesByAddress = co(function* getHashesByAddress(addresses
|
||||
hash = Address.getHash(address);
|
||||
|
||||
if (!hash)
|
||||
continue;
|
||||
throw new Error('Not an address.');
|
||||
|
||||
yield this.db.keys({
|
||||
gte: layout.T(hash, encoding.ZERO_HASH),
|
||||
@ -1217,8 +1216,8 @@ ChainDB.prototype.getMetaByAddress = co(function* getTXByAddress(addresses) {
|
||||
for (i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i];
|
||||
tx = yield this.getMeta(hash);
|
||||
if (tx)
|
||||
txs.push(tx);
|
||||
assert(tx);
|
||||
txs.push(tx);
|
||||
}
|
||||
|
||||
return txs;
|
||||
|
||||
@ -554,7 +554,7 @@ Mempool.prototype.getCoinsByAddress = function getCoinsByAddress(addresses) {
|
||||
hash = Address.getHash(addresses[i], 'hex');
|
||||
|
||||
if (!hash)
|
||||
continue;
|
||||
throw new Error('Not an address.');
|
||||
|
||||
coin = this.coinIndex.get(hash);
|
||||
|
||||
@ -582,7 +582,7 @@ Mempool.prototype.getTXByAddress = function getTXByAddress(addresses) {
|
||||
hash = Address.getHash(addresses[i], 'hex');
|
||||
|
||||
if (!hash)
|
||||
continue;
|
||||
throw new Error('Not an address.');
|
||||
|
||||
tx = this.txIndex.get(hash);
|
||||
|
||||
@ -610,7 +610,7 @@ Mempool.prototype.getMetaByAddress = function getMetaByAddress(addresses) {
|
||||
hash = Address.getHash(addresses[i], 'hex');
|
||||
|
||||
if (!hash)
|
||||
continue;
|
||||
throw new Error('Not an address.');
|
||||
|
||||
tx = this.txIndex.getMeta(hash);
|
||||
|
||||
@ -1428,8 +1428,7 @@ Mempool.prototype.getBalance = function getBalance() {
|
||||
hash = hashes[i];
|
||||
tx = this.getTX(hash);
|
||||
|
||||
if (!tx)
|
||||
continue;
|
||||
assert(tx);
|
||||
|
||||
hash = tx.hash('hex');
|
||||
|
||||
@ -1457,8 +1456,7 @@ Mempool.prototype.getHistory = function getHistory() {
|
||||
hash = hashes[i];
|
||||
tx = this.getTX(hash);
|
||||
|
||||
if (!tx)
|
||||
continue;
|
||||
assert(tx);
|
||||
|
||||
txs.push(tx);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user