-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mempool interfaces (#13249)
* working out interfaces * integration to checkTx * use struct fields directly in sz calculation * fix typo * nil guard on mempool * Remove tx builder method * impl with panic
- Loading branch information
1 parent
c32493a
commit b96bed5
Showing
6 changed files
with
60 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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 | ||
} |
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