cosmos-sdk/types/mempool.go

32 lines
1.1 KiB
Go

package types
// MempoolTx we define an app-side mempool transaction interface that is as
// minimal as possible, only requiring applications to define the size of the
// transaction to be used when reaping and getting the transaction itself.
// Interface type casting can be used in the actual app-side mempool implementation.
type MempoolTx interface {
Tx
// Size returns the size of the transaction in bytes.
Size() int
}
type Mempool interface {
// Insert attempts to insert a MempoolTx into the app-side mempool returning
// an error upon failure.
Insert(Context, MempoolTx) error
// Select returns the next set of available transactions from the app-side
// mempool, up to maxBytes or until the mempool is empty. The application can
// decide to return transactions from its own mempool, from the incoming
// txs, or some combination of both.
Select(ctx Context, txs [][]byte, maxBytes int) ([]MempoolTx, error)
// CountTx returns the number of transactions currently in the mempool.
CountTx() int
// Remove attempts to remove a transaction from the mempool, returning an error
// upon failure.
Remove(Context, MempoolTx) error
}