new Mempool(options)
Represents a mempool.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Properties:
Name | Type | Description |
---|---|---|
loaded |
Boolean | |
db |
Object | |
size |
Number | |
orphans |
Number | |
locker |
Locker | |
freeCount |
Number | |
lastTime |
Number | |
backend |
String |
- Source:
Fires:
- Mempool#event:open
- Mempool#event:error
- Mempool#event:tx
- Mempool#event:add tx
- Mempool#event:remove tx
Methods
(private) _addUnchecked(tx, callback)
Add a transaction to the mempool database.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function |
- Source:
(private) _removeUnchecked(hash, callback)
Remove a transaction from the database. Note that this may not disconnect the inputs.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function |
- Source:
addBlock(block, callback)
Notify the mempool that a new block has come in (removes all transactions contained in the block from the mempool).
Parameters:
Name | Type | Description |
---|---|---|
block |
Block | |
callback |
function |
- Source:
addTX(tx, callback)
Add a transaction to the mempool. Note that this will lock the mempool until the transaction is fully processed.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [VerifyError]. |
- Source:
addUnchecked(tx, callback)
Add a transaction to the mempool without performing any validation. Note that this method does not lock the mempool and may lend itself to race conditions if used unwisely. This function will also resolve orphans if possible (the resolved orphans will be validated).
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [VerifyError]. |
- Source:
checkLocks(tx, flags, callback)
Check sequence locks on a transaction against the current tip.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
flags |
LockFlags | |
callback |
function | Returns [Error, Boolean]. |
- Source:
close(callback)
Close the chain, wait for the database to close.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
countAncestors(tx, callback)
Count the highest number of ancestors a transaction may have.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, Number]. |
- Source:
fillAllCoins(tx, callback)
Fill transaction with all unspent coins. Similar to Mempool#fillCoins except that it will also fill with coins from the blockchain as well.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
fillAllHistory(tx, callback)
Fill transaction with all unspent and spent coins. Similar to Mempool#fillHistory except that it will also fill with coins from the blockchain as well.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
fillCoins(tx, callback)
Fill a transaction with all available (unspent) coins in the mempool.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
fillHistory(tx, callback)
Fill a transaction with all available transaction outputs in the mempool. This differs from Mempool#fillCoins in that it will fill with all historical coins and not just unspent coins.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
getBalance()
Return the full balance of all unspents in the mempool (not very useful in practice, only used for testing).
- Source:
getCoin(hash, index, callback)
Retrieve a coin from the mempool (unspents only).
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number | |
callback |
function | Returns [Error, Coin]. |
- Source:
getCoinsByAddress(addresses, callback)
Find all coins pertaining to a certain address.
Parameters:
Name | Type | Description |
---|---|---|
addresses |
Array.<Base58Address> | Base58Address | |
callback |
function | Returns [Error, Coin[]]. |
- Source:
getConfidence(hash, callback)
Calculate bitcoinj-style confidence.
Parameters:
Name | Type | Description |
---|---|---|
hash |
TX | Hash | |
callback |
function | Returns [Error, Number]. |
- Source:
- See:
getHistory(callback)
Retrieve all transactions from the mempool.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Returns [Error, TX[]]. |
- Source:
getOrphan(orphanHash, callback)
Retrieve an orphan transaction.
Parameters:
Name | Type | Description |
---|---|---|
orphanHash |
Hash | |
callback |
function | Returns [Error, TX]. |
- Source:
getSnapshot(callback)
Get a snapshot of all transaction hashes in the mempool. Used for generating INV packets in response to MEMPOOL packets.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Returns [Error, Hash[]]. |
- Source:
getTX(hash, callback)
Retrieve a transaction from the mempool. Note that this will not be filled with coins.
Parameters:
Name | Type | Description |
---|---|---|
hash |
TX | Hash | |
callback |
function | Returns [Error, TX]. |
- Source:
getTXByAddress(addresses, callback)
Find all transactions pertaining to a certain address.
Parameters:
Name | Type | Description |
---|---|---|
addresses |
Array.<Base58Address> | Base58Address | |
callback |
function | Returns [Error, TX[]]. |
- Source:
getWaiting(hash, callback)
Get hashes of all orphans a transaction hash potentially resolves.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | Resolving transaction. |
callback |
function | Return [Error, Hash[]]. |
- Source:
hasOrphan(orphanHash, callback)
Parameters:
Name | Type | Description |
---|---|---|
orphanHash |
Hash | |
callback |
function | Returns [Error, Boolean]. |
- Source:
hasTX(hash, callback)
Test the mempool to see if it contains a transaction.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error, Boolean]. |
- Source:
isDoubleSpend(tx, callback)
Test all of a transactions outpoints to see if they are doublespends. Note that this will only test against the mempool spents, not the blockchain's. The blockchain spents are not checked against because the blockchain does not maintain a spent list. The transaction will be seen as an orphan rather than a double spend.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, Boolean]. |
- Source:
isSpent(hash, index, callback)
Check to see if a coin has been spent. This differs from
ChainDB#isSpent in that it actually maintains a
map of spent coins, whereas ChainDB may return true
for transaction outputs that never existed.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number | |
callback |
function | Returns [Error, Boolean]. |
- Source:
limitMempoolSize(callback)
Ensure the size of the mempool stays below 300mb.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
open(callback)
Open the chain, wait for the database to load.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
purgeOrphans(callback)
Purge orphan transactions from the mempool.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
purgePending()
Purge pending txs in the queue.
- Source:
removeBlock(block, callback)
Notify the mempool that a block has been disconnected from the main chain (reinserts transactions into the mempool).
Parameters:
Name | Type | Description |
---|---|---|
block |
Block | |
callback |
function |
- Source:
removeOrphan(tx, callback)
Remove a transaction from the mempool.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | Hash | |
callback |
function |
- Source:
removeUnchecked(tx, callback)
Remove a transaction from the mempool. Generally only called when a new block is added to the main chain.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function |
- Source:
resolveOrphans(tx, callback)
Potentially resolve any transactions that redeem the passed-in transaction. Deletes all orphan entries and returns orphan hashes.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, Hash[]]. |
- Source:
seenTX(tx, callback)
Test a transaction hash to see if it has been seen as an orphan, in the mempool, or in the blockchain. This is the closest thing to a function named "DoesThisTransactionExist()".
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, Boolean]. |
- Source:
storeOrphan(tx, callback)
Store an orphaned transaction.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function |
- Source:
verify(tx, callback)
Verify a transaction with mempool standards.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [VerifyError]. |
- Source: