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