mempool: clean up comments. misc.
This commit is contained in:
parent
31d2f36c42
commit
53f209dda5
@ -81,8 +81,6 @@ function Fullnode(options) {
|
|||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
chain: this.chain,
|
chain: this.chain,
|
||||||
fees: this.fees,
|
fees: this.fees,
|
||||||
db: 'memory',
|
|
||||||
location: this.location('mempool'),
|
|
||||||
limitFree: this.options.limitFree,
|
limitFree: this.options.limitFree,
|
||||||
limitFreeRelay: this.options.limitFreeRelay,
|
limitFreeRelay: this.options.limitFreeRelay,
|
||||||
requireStandard: this.options.requireStandard,
|
requireStandard: this.options.requireStandard,
|
||||||
@ -504,23 +502,21 @@ Fullnode.prototype.getCoin = function getCoin(hash, index, callback) {
|
|||||||
Fullnode.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, callback) {
|
Fullnode.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var coins = this.mempool.getCoinsByAddress(addresses);
|
var coins = this.mempool.getCoinsByAddress(addresses);
|
||||||
|
var i, coin, spent;
|
||||||
|
|
||||||
this.chain.db.getCoinsByAddress(addresses, function(err, blockCoins) {
|
this.chain.db.getCoinsByAddress(addresses, function(err, blockCoins) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
||||||
utils.forEach(blockCoins, function(coin, next) {
|
for (i = 0; i < blockCoins.length; i++) {
|
||||||
var spent = self.mempool.isSpent(coin.hash, coin.index);
|
coin = blockCoins[i];
|
||||||
|
spent = self.mempool.isSpent(coin.hash, coin.index);
|
||||||
|
|
||||||
if (!spent)
|
if (!spent)
|
||||||
coins.push(coin);
|
coins.push(coin);
|
||||||
|
}
|
||||||
|
|
||||||
return next();
|
return callback(null, coins);
|
||||||
}, function(err) {
|
|
||||||
if (err)
|
|
||||||
return callback(err);
|
|
||||||
return callback(null, coins);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -248,7 +248,7 @@ Mempool.prototype.removeBlock = function removeBlock(block, callback, force) {
|
|||||||
Mempool.prototype.limitMempoolSize = function limitMempoolSize(entryHash, callback) {
|
Mempool.prototype.limitMempoolSize = function limitMempoolSize(entryHash, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var trimmed = false;
|
var trimmed = false;
|
||||||
var end, hashes, entry;
|
var hashes, end, entry;
|
||||||
|
|
||||||
if (this.getSize() <= this.maxSize)
|
if (this.getSize() <= this.maxSize)
|
||||||
return callback(null, trimmed);
|
return callback(null, trimmed);
|
||||||
@ -279,6 +279,8 @@ Mempool.prototype.limitMempoolSize = function limitMempoolSize(entryHash, callba
|
|||||||
if (self.getSize() <= self.maxSize)
|
if (self.getSize() <= self.maxSize)
|
||||||
return callback(null, trimmed);
|
return callback(null, trimmed);
|
||||||
|
|
||||||
|
hashes = Object.keys(self.tx);
|
||||||
|
|
||||||
utils.forEachSerial(hashes, function(hash, next) {
|
utils.forEachSerial(hashes, function(hash, next) {
|
||||||
if (self.getSize() <= self.maxSize)
|
if (self.getSize() <= self.maxSize)
|
||||||
return callback(null, trimmed);
|
return callback(null, trimmed);
|
||||||
@ -324,7 +326,7 @@ Mempool.prototype.limitOrphans = function limitOrphans() {
|
|||||||
* Retrieve a transaction from the mempool.
|
* Retrieve a transaction from the mempool.
|
||||||
* Note that this will not be filled with coins.
|
* Note that this will not be filled with coins.
|
||||||
* @param {TX|Hash} hash
|
* @param {TX|Hash} hash
|
||||||
* @param {Function} callback - Returns [Error, {@link TX}].
|
* @returns {TX}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getTX = function getTX(hash) {
|
Mempool.prototype.getTX = function getTX(hash) {
|
||||||
@ -338,7 +340,7 @@ Mempool.prototype.getTX = function getTX(hash) {
|
|||||||
* Retrieve a transaction from the mempool.
|
* Retrieve a transaction from the mempool.
|
||||||
* Note that this will not be filled with coins.
|
* Note that this will not be filled with coins.
|
||||||
* @param {TX|Hash} hash
|
* @param {TX|Hash} hash
|
||||||
* @param {Function} callback - Returns [Error, {@link TX}].
|
* @returns {MempoolEntry}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getEntry = function getEntry(hash) {
|
Mempool.prototype.getEntry = function getEntry(hash) {
|
||||||
@ -349,7 +351,7 @@ Mempool.prototype.getEntry = function getEntry(hash) {
|
|||||||
* Retrieve a coin from the mempool (unspents only).
|
* Retrieve a coin from the mempool (unspents only).
|
||||||
* @param {Hash} hash
|
* @param {Hash} hash
|
||||||
* @param {Number} index
|
* @param {Number} index
|
||||||
* @param {Function} callback - Returns [Error, {@link Coin}].
|
* @returns {Coin}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getCoin = function getCoin(hash, index) {
|
Mempool.prototype.getCoin = function getCoin(hash, index) {
|
||||||
@ -374,7 +376,7 @@ Mempool.prototype.getCoin = function getCoin(hash, index) {
|
|||||||
* for transaction outputs that never existed.
|
* for transaction outputs that never existed.
|
||||||
* @param {Hash} hash
|
* @param {Hash} hash
|
||||||
* @param {Number} index
|
* @param {Number} index
|
||||||
* @param {Function} callback - Returns [Error, Boolean].
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.isSpent = function isSpent(hash, index) {
|
Mempool.prototype.isSpent = function isSpent(hash, index) {
|
||||||
@ -383,8 +385,8 @@ Mempool.prototype.isSpent = function isSpent(hash, index) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all coins pertaining to a certain address.
|
* Find all coins pertaining to a certain address.
|
||||||
* @param {Base58Address|Base58Address[]} addresses
|
* @param {Address[]} addresses
|
||||||
* @param {Function} callback - Returns [Error, {@link Coin}[]].
|
* @returns {Coin[]}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getCoinsByAddress = function getCoinsByAddress(addresses) {
|
Mempool.prototype.getCoinsByAddress = function getCoinsByAddress(addresses) {
|
||||||
@ -399,7 +401,7 @@ Mempool.prototype.getCoinsByAddress = function getCoinsByAddress(addresses) {
|
|||||||
if (!hash)
|
if (!hash)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
coin = this.coinIndex.searchCoin(hash);
|
coin = this.coinIndex.getCoins(hash);
|
||||||
|
|
||||||
for (j = 0; j < coin.length; j++)
|
for (j = 0; j < coin.length; j++)
|
||||||
coins.push(coin[j]);
|
coins.push(coin[j]);
|
||||||
@ -410,8 +412,8 @@ Mempool.prototype.getCoinsByAddress = function getCoinsByAddress(addresses) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all transactions pertaining to a certain address.
|
* Find all transactions pertaining to a certain address.
|
||||||
* @param {Base58Address|Base58Address[]} addresses
|
* @param {Address[]} addresses
|
||||||
* @param {Function} callback - Returns [Error, {@link TX}[]].
|
* @returns {TX[]}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getTXByAddress = function getTXByAddress(addresses) {
|
Mempool.prototype.getTXByAddress = function getTXByAddress(addresses) {
|
||||||
@ -426,7 +428,7 @@ Mempool.prototype.getTXByAddress = function getTXByAddress(addresses) {
|
|||||||
if (!hash)
|
if (!hash)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tx = this.txIndex.searchTX(hash);
|
tx = this.txIndex.getTX(hash);
|
||||||
|
|
||||||
for (j = 0; j < tx.length; j++)
|
for (j = 0; j < tx.length; j++)
|
||||||
txs.push(tx[j]);
|
txs.push(tx[j]);
|
||||||
@ -441,7 +443,6 @@ Mempool.prototype.getTXByAddress = function getTXByAddress(addresses) {
|
|||||||
* in that it will fill with all historical coins and not
|
* in that it will fill with all historical coins and not
|
||||||
* just unspent coins.
|
* just unspent coins.
|
||||||
* @param {TX} tx
|
* @param {TX} tx
|
||||||
* @param {Function} callback - Returns [Error, {@link TX}].
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.fillHistory = function fillHistory(tx) {
|
Mempool.prototype.fillHistory = function fillHistory(tx) {
|
||||||
@ -470,7 +471,6 @@ Mempool.prototype.fillHistory = function fillHistory(tx) {
|
|||||||
* Fill a transaction with all available (unspent) coins
|
* Fill a transaction with all available (unspent) coins
|
||||||
* in the mempool.
|
* in the mempool.
|
||||||
* @param {TX} tx
|
* @param {TX} tx
|
||||||
* @param {Function} callback - Returns [Error, {@link TX}].
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.fillCoins = function fillCoins(tx) {
|
Mempool.prototype.fillCoins = function fillCoins(tx) {
|
||||||
@ -498,7 +498,7 @@ Mempool.prototype.fillCoins = function fillCoins(tx) {
|
|||||||
/**
|
/**
|
||||||
* Test the mempool to see if it contains a transaction.
|
* Test the mempool to see if it contains a transaction.
|
||||||
* @param {Hash} hash
|
* @param {Hash} hash
|
||||||
* @param {Function} callback - Returns [Error, Boolean].
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.hasTX = function hasTX(hash) {
|
Mempool.prototype.hasTX = function hasTX(hash) {
|
||||||
@ -508,7 +508,7 @@ Mempool.prototype.hasTX = function hasTX(hash) {
|
|||||||
/**
|
/**
|
||||||
* Test the mempool to see if it contains a transaction or an orphan.
|
* Test the mempool to see if it contains a transaction or an orphan.
|
||||||
* @param {Hash} hash
|
* @param {Hash} hash
|
||||||
* @param {Function} callback - Returns [Error, Boolean].
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.has = function has(hash) {
|
Mempool.prototype.has = function has(hash) {
|
||||||
@ -963,7 +963,7 @@ Mempool.prototype.verify = function verify(entry, callback) {
|
|||||||
* Count the highest number of
|
* Count the highest number of
|
||||||
* ancestors a transaction may have.
|
* ancestors a transaction may have.
|
||||||
* @param {TX} tx
|
* @param {TX} tx
|
||||||
* @param {Function} callback - Returns [Error, Number].
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.countAncestors = function countAncestors(tx) {
|
Mempool.prototype.countAncestors = function countAncestors(tx) {
|
||||||
@ -988,7 +988,7 @@ Mempool.prototype.countAncestors = function countAncestors(tx) {
|
|||||||
* Count the highest number of
|
* Count the highest number of
|
||||||
* descendants a transaction may have.
|
* descendants a transaction may have.
|
||||||
* @param {TX} tx
|
* @param {TX} tx
|
||||||
* @param {Function} callback - Returns [Error, Number].
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.countDescendants = function countDescendants(tx) {
|
Mempool.prototype.countDescendants = function countDescendants(tx) {
|
||||||
@ -1013,7 +1013,7 @@ Mempool.prototype.countDescendants = function countDescendants(tx) {
|
|||||||
* Find a unconfirmed transactions that
|
* Find a unconfirmed transactions that
|
||||||
* this transaction depends on.
|
* this transaction depends on.
|
||||||
* @param {TX} tx
|
* @param {TX} tx
|
||||||
* @param {Function} callback - Returns [Error, Number].
|
* @returns {Hash[]}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getDepends = function getDepends(tx) {
|
Mempool.prototype.getDepends = function getDepends(tx) {
|
||||||
@ -1077,6 +1077,7 @@ Mempool.prototype.storeOrphan = function storeOrphan(tx) {
|
|||||||
/**
|
/**
|
||||||
* Return the full balance of all unspents in the mempool
|
* Return the full balance of all unspents in the mempool
|
||||||
* (not very useful in practice, only used for testing).
|
* (not very useful in practice, only used for testing).
|
||||||
|
* @returns {Amount}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getBalance = function getBalance() {
|
Mempool.prototype.getBalance = function getBalance() {
|
||||||
@ -1100,7 +1101,7 @@ Mempool.prototype.getBalance = function getBalance() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve _all_ transactions from the mempool.
|
* Retrieve _all_ transactions from the mempool.
|
||||||
* @param {Function} callback - Returns [Error, {@link TX}[]].
|
* @returns {TX[]}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getHistory = function getHistory() {
|
Mempool.prototype.getHistory = function getHistory() {
|
||||||
@ -1396,7 +1397,6 @@ Mempool.prototype.getConfidence = function getConfidence(hash, callback) {
|
|||||||
* Add a transaction to the mempool database.
|
* Add a transaction to the mempool database.
|
||||||
* @private
|
* @private
|
||||||
* @param {MempoolEntry} entry
|
* @param {MempoolEntry} entry
|
||||||
* @param {Function} callback
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype._addUnchecked = function _addUnchecked(entry) {
|
Mempool.prototype._addUnchecked = function _addUnchecked(entry) {
|
||||||
@ -1840,7 +1840,7 @@ function AddressIndex(mempool) {
|
|||||||
this.map = {};
|
this.map = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressIndex.prototype.searchCoin = function searchCoin(address) {
|
AddressIndex.prototype.getCoins = function getCoins(address) {
|
||||||
var items = this.map[address];
|
var items = this.map[address];
|
||||||
var out = [];
|
var out = [];
|
||||||
var i, item, outpoint, coin;
|
var i, item, outpoint, coin;
|
||||||
@ -1859,7 +1859,7 @@ AddressIndex.prototype.searchCoin = function searchCoin(address) {
|
|||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
AddressIndex.prototype.searchTX = function searchTX(address) {
|
AddressIndex.prototype.getTX = function getTX(address) {
|
||||||
var items = this.map[address];
|
var items = this.map[address];
|
||||||
var out = [];
|
var out = [];
|
||||||
var i, hash, tx;
|
var i, hash, tx;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user