-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nonce (sequence number) based mempool (#13645)
simple default mempool implementation Co-authored-by: Jeancarlo <[email protected]>
- Loading branch information
1 parent
a19c3a6
commit 2418c3e
Showing
12 changed files
with
625 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
package types | ||
package mempool | ||
|
||
// MempoolTx we define an app-side mempool transaction interface that is as | ||
import ( | ||
"errors" | ||
|
||
"github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Tx defines 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. | ||
// transaction to be used when inserting, selecting, and deleting the transaction. | ||
// Interface type casting can be used in the actual app-side mempool implementation. | ||
type MempoolTx interface { | ||
Tx | ||
type Tx interface { | ||
types.Tx | ||
|
||
// Size returns the size of the transaction in bytes. | ||
Size() int | ||
Size() int64 | ||
} | ||
|
||
type Mempool interface { | ||
// Insert attempts to insert a MempoolTx into the app-side mempool returning | ||
// Insert attempts to insert a Tx into the app-side mempool returning | ||
// an error upon failure. | ||
Insert(Context, MempoolTx) error | ||
Insert(types.Context, Tx) 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) | ||
Select(txs [][]byte, maxBytes int64) ([]Tx, 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 | ||
Remove(Tx) error | ||
} | ||
|
||
var ErrTxNotFound = errors.New("tx not found in mempool") | ||
|
||
type Factory func() Mempool |
Oops, something went wrong.