Documentation
¶
Index ¶
- Variables
- type Mempool
- type Txs
- func (t *Txs) CancelCurrentTx(txID ids.ID)
- func (t *Txs) CancelCurrentTxs()
- func (t *Txs) DiscardCurrentTx(txID ids.ID)
- func (t *Txs) DiscardCurrentTxs()
- func (t *Txs) GetPendingTx(txID ids.ID) (*atomic.Tx, bool)
- func (t *Txs) GetTx(txID ids.ID) (tx *atomic.Tx, discarded bool, found bool)
- func (t *Txs) Has(txID ids.ID) bool
- func (t *Txs) IssueCurrentTxs()
- func (t *Txs) Iterate(f func(tx *atomic.Tx) bool)
- func (t *Txs) NextTx() (*atomic.Tx, bool)
- func (t *Txs) PendingLen() int
- func (t *Txs) RemoveTx(tx *atomic.Tx)
- func (t *Txs) SubscribePendingTxs() <-chan struct{}
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Mempool ¶
type Mempool struct {
*Txs
// contains filtered or unexported fields
}
Mempool is a simple mempool for atomic transactions
func NewMempool ¶
func NewMempool( txs *Txs, registerer prometheus.Registerer, verify func(tx *atomic.Tx) error, ) (*Mempool, error)
func (*Mempool) Add ¶
Add attempts to add tx to the mempool as a Remote transaction. It is assumed the snow context lock is not held.
func (*Mempool) AddLocalTx ¶
AddLocalTx attempts to add tx to the mempool as a Local transaction.
Local transactions are not checked for recent verification failures prior to performing verification. Even if a Local transaction failed verification recently, the mempool will attempt to re-verify it.
func (*Mempool) AddRemoteTx ¶
AddRemoteTx attempts to add tx to the mempool as a Remote transaction.
Remote transactions are checked for recent verification failures prior to performing verification. If a Remote transaction failed verification recently it will not be added to the mempool.
func (*Mempool) ForceAddTx ¶
ForceAddTx forcibly adds a tx to the mempool and bypasses all verification.
type Txs ¶ added in v0.15.3
type Txs struct {
// contains filtered or unexported fields
}
Txs stores the transactions inside of the mempool.
Transactions in the mempool can be in 1 of 4 statuses:
- Pending: Pending transactions are eligible for the block builder to attempt to include in the next block being built.
- Current: Current transactions are included inside of a block currently being built.
- Issued: Issued transactions were included inside of a block built by this node.
- Discarded: Discarded transactions were previously in the the mempool, but were then deemed to be invalid. To prevent additional future work, these transactions may be assumed to be invalid in the future.
func (*Txs) CancelCurrentTx ¶ added in v0.15.3
CancelCurrentTx attempts to mark the Current transaction as Pending.
This should be called after Txs.NextTx returned the transaction and it couldn't be included in the block, but should not be discarded. For example, CancelCurrentTx should be called if including the transaction will put the block above the atomic tx gas limit.
func (*Txs) CancelCurrentTxs ¶ added in v0.15.3
func (t *Txs) CancelCurrentTxs()
CancelCurrentTxs attempts to mark all Current transactions as Pending.
This should be called after building a block failed due to an error unrelated to the transactions.
func (*Txs) DiscardCurrentTx ¶ added in v0.15.3
DiscardCurrentTx marks the Current transaction as Discarded.
This should be called after Txs.NextTx returned the transaction and it failed verification. For example, DiscardCurrentTx should be called if including the transaction would produce a conflict with an ancestor block.
func (*Txs) DiscardCurrentTxs ¶ added in v0.15.3
func (t *Txs) DiscardCurrentTxs()
DiscardCurrentTxs marks all Current transactions as Discarded.
This should be called after building a block failed due to an error related to the transactions.
func (*Txs) GetPendingTx ¶ added in v0.15.3
GetPendingTx returns the transaction if it is Pending.
func (*Txs) Has ¶ added in v0.15.3
Has returns true if the mempool contains the transaction in either the Pending, Current, or Issued state.
func (*Txs) IssueCurrentTxs ¶ added in v0.15.3
func (t *Txs) IssueCurrentTxs()
IssueCurrentTxs marks all Current transactions as Issued.
func (*Txs) Iterate ¶ added in v0.15.3
Iterate applies f to all Pending transactions. If f returns false, the iteration stops early.
func (*Txs) NextTx ¶ added in v0.15.3
NextTx returns the highest paying Pending transaction from the mempool and marks it as Current.
func (*Txs) PendingLen ¶ added in v0.15.3
PendingLen returns the number of pending transactions.
func (*Txs) RemoveTx ¶ added in v0.15.3
RemoveTx removes the transaction from the mempool, including removal of the Discarded status.
func (*Txs) SubscribePendingTxs ¶ added in v0.15.3
func (t *Txs) SubscribePendingTxs() <-chan struct{}
SubscribePendingTxs returns a channel that signals when there is a transaction added to the mempool.