-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(FS): Moving Types to Base Subdirectory (#19)
* init * updating readme (cherry picked from commit c956e6c)
- Loading branch information
1 parent
394b30a
commit a8649c6
Showing
9 changed files
with
93 additions
and
84 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,66 @@ | ||
package base | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/skip-mev/block-sdk/block" | ||
) | ||
|
||
type ( | ||
// MatchHandler is utilized to determine if a transaction should be included in the lane. This | ||
// function can be a stateless or stateful check on the transaction. | ||
MatchHandler func(ctx sdk.Context, tx sdk.Tx) bool | ||
|
||
// PrepareLaneHandler is responsible for preparing transactions to be included in the block from a | ||
// given lane. Given a lane, this function should return the transactions to include in the block, | ||
// the transactions that must be removed from the lane, and an error if one occurred. | ||
PrepareLaneHandler func( | ||
ctx sdk.Context, | ||
proposal block.BlockProposal, | ||
maxTxBytes int64, | ||
) (txsToInclude [][]byte, txsToRemove []sdk.Tx, err error) | ||
|
||
// ProcessLaneHandler is responsible for processing transactions that are included in a block and | ||
// belong to a given lane. ProcessLaneHandler is executed after CheckOrderHandler so the transactions | ||
// passed into this function SHOULD already be in order respecting the ordering rules of the lane and | ||
// respecting the ordering rules of mempool relative to the lanes it has. | ||
ProcessLaneHandler func(ctx sdk.Context, txs []sdk.Tx) ([]sdk.Tx, error) | ||
|
||
// CheckOrderHandler is responsible for checking the order of transactions that belong to a given | ||
// lane. This handler should be used to verify that the ordering of transactions passed into the | ||
// function respect the ordering logic of the lane (if any transactions from the lane are included). | ||
// This function should also ensure that transactions that belong to this lane are contiguous and do | ||
// not have any transactions from other lanes in between them. | ||
CheckOrderHandler func(ctx sdk.Context, txs []sdk.Tx) error | ||
) | ||
|
||
// NoOpPrepareLaneHandler returns a no-op prepare lane handler. | ||
// This should only be used for testing. | ||
func NoOpPrepareLaneHandler() PrepareLaneHandler { | ||
return func(ctx sdk.Context, proposal block.BlockProposal, maxTxBytes int64) (txsToInclude [][]byte, txsToRemove []sdk.Tx, err error) { | ||
return nil, nil, nil | ||
} | ||
} | ||
|
||
// PanicPrepareLaneHandler returns a prepare lane handler that panics. | ||
// This should only be used for testing. | ||
func PanicPrepareLaneHandler() PrepareLaneHandler { | ||
return func(sdk.Context, block.BlockProposal, int64) (txsToInclude [][]byte, txsToRemove []sdk.Tx, err error) { | ||
panic("panic prepare lanes handler") | ||
} | ||
} | ||
|
||
// NoOpProcessLaneHandler returns a no-op process lane handler. | ||
// This should only be used for testing. | ||
func NoOpProcessLaneHandler() ProcessLaneHandler { | ||
return func(ctx sdk.Context, txs []sdk.Tx) ([]sdk.Tx, error) { | ||
return txs, nil | ||
} | ||
} | ||
|
||
// PanicProcessLanesHandler returns a process lanes handler that panics. | ||
// This should only be used for testing. | ||
func PanicProcessLaneHandler() ProcessLaneHandler { | ||
return func(sdk.Context, []sdk.Tx) ([]sdk.Tx, error) { | ||
panic("panic process lanes handler") | ||
} | ||
} |
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