TxPool
Tx pool (mempool)
Memberof
module:service
Constructors
new TxPool()
new TxPool(
options
):TxPool
Create new tx pool
Parameters
• options: TxPoolOptions
constructor parameters
Returns
Defined in
Properties
BLOCKS_BEFORE_TARGET_HEIGHT_ACTIVATION
BLOCKS_BEFORE_TARGET_HEIGHT_ACTIVATION:
number
=20
Activate before chain head is reached to start tx pool preparation (sorting out included txs)
Defined in
HANDLED_CLEANUP_TIME_LIMIT
HANDLED_CLEANUP_TIME_LIMIT:
number
=60
Number of minutes to forget about handled txs (for cleanup/memory reasons)
Defined in
POOLED_STORAGE_TIME_LIMIT
POOLED_STORAGE_TIME_LIMIT:
number
=20
Number of minutes to keep txs in the pool
Defined in
pool
pool:
Map
<string
,TxPoolObject
[]>
The central pool dataset.
Maps an address to a TxPoolObject
Defined in
running
running:
boolean
Defined in
txsInPool
txsInPool:
number
The number of txs currently in the pool
Defined in
Methods
_logPoolStats()
_logPoolStats():
void
Returns
void
Defined in
add()
add(
tx
,requireSignature
,skipBalance
):Promise
<void
>
Adds a tx to the pool.
If there is a tx in the pool with the same address and nonce it will be replaced by the new tx, if it has a sufficient gas bump. This also verifies certain constraints, if these are not met, tx will not be added to the pool.
Parameters
• tx: TypedTransaction
| ImpersonatedTx
Transaction
• requireSignature: boolean
= true
• skipBalance: boolean
= false
Returns
Promise
<void
>
Defined in
addUnverified()
addUnverified(
tx
):Promise
<void
>
Adds a tx to the pool without validating it.
If there is a tx in the pool with the same address and nonce it will be replaced by the new tx, if it has a sufficient gas bump. This also verifies certain constraints, if these are not met, tx will not be added to the pool.
Parameters
• tx: TypedTransaction
| ImpersonatedTx
Transaction
Returns
Promise
<void
>
Defined in
cleanup()
cleanup():
void
Regular tx pool cleanup
Returns
void
Defined in
close()
close():
void
Close pool
Returns
void
Defined in
deepCopy()
deepCopy(
opt
):TxPool
Parameters
• opt: TxPoolOptions
Returns
Defined in
getByHash()
getByHash(
txHashes
): (TypedTransaction
|ImpersonatedTx
)[]
Returns the available txs from the pool
Parameters
• txHashes: readonly Uint8Array
[]
Returns
(TypedTransaction
| ImpersonatedTx
)[]
Array with tx objects
Defined in
getBySenderAddress()
getBySenderAddress(
address
):Promise
<TxPoolObject
[]>
Parameters
• address: EthjsAddress
Returns
Promise
<TxPoolObject
[]>
Defined in
open()
open():
boolean
Open pool
Returns
boolean
Defined in
removeByHash()
removeByHash(
txHash
):void
Removes the given tx from the pool
Parameters
• txHash: string
Hash of the transaction
Returns
void
Defined in
removeNewBlockTxs()
removeNewBlockTxs(
newBlocks
):void
Remove txs included in the latest blocks from the tx pool
Parameters
• newBlocks: Block
[]
Returns
void
Defined in
start()
start():
boolean
Start tx processing
Returns
boolean
Defined in
stop()
stop():
boolean
Stop pool execution
Returns
boolean
Defined in
txsByPriceAndNonce()
txsByPriceAndNonce(
baseFee
):Promise
<(TypedTransaction
|ImpersonatedTx
)[]>
Returns eligible txs to be mined sorted by price in such a way that the nonce orderings within a single account are maintained.
Note, this is not as trivial as it seems from the first look as there are three different criteria that need to be taken into account (price, nonce, account match), which cannot be done with any plain sorting method, as certain items cannot be compared without context.
This method first sorts the separates the list of transactions into individual sender accounts and sorts them by nonce. After the account nonce ordering is satisfied, the results are merged back together by price, always comparing only the head transaction from each account. This is done via a heap to keep it fast.
Parameters
• baseFee = {}
Provide a baseFee to exclude txs with a lower gasPrice
• baseFee.allowedBlobs?: number
• baseFee.baseFee?: bigint
Returns
Promise
<(TypedTransaction
| ImpersonatedTx
)[]>