Documentation
¶
Index ¶
- type IgnoreDecorator
- type Lane
- type LaneMempool
- type LanedMempool
- func (m *LanedMempool) Contains(tx sdk.Tx) (contains bool)
- func (m *LanedMempool) CountTx() int
- func (m *LanedMempool) GetTxDistribution() map[string]int
- func (m *LanedMempool) Insert(ctx context.Context, tx sdk.Tx) (err error)
- func (m *LanedMempool) Registry() []Lane
- func (m *LanedMempool) Remove(tx sdk.Tx) (err error)
- func (m *LanedMempool) Select(_ context.Context, _ [][]byte) sdkmempool.Iterator
- func (m *LanedMempool) ValidateBasic() error
- type Mempool
- type PrepareLanesHandler
- type ProcessLanesHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IgnoreDecorator ¶ added in v1.1.0
type IgnoreDecorator struct {
// contains filtered or unexported fields
}
IgnoreDecorator is an AnteDecorator that wraps an existing AnteDecorator. It allows for the AnteDecorator to be ignored for specified lanes.
func NewIgnoreDecorator ¶ added in v1.1.0
func NewIgnoreDecorator(decorator sdk.AnteDecorator, lanes ...Lane) *IgnoreDecorator
NewIgnoreDecorator returns a new IgnoreDecorator instance.
func (IgnoreDecorator) AnteHandle ¶ added in v1.1.0
func (sd IgnoreDecorator) AnteHandle( ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler, ) (sdk.Context, error)
AnteHandle implements the sdk.AnteDecorator interface. If the transaction belongs to one of the lanes, the next AnteHandler is called. Otherwise, the decorator's AnteHandler is called.
type Lane ¶
type Lane interface {
LaneMempool
// PrepareLane builds a portion of the block. It inputs the current context, proposal, and a
// function to call the next lane in the chain. This handler should update the context as needed
// and add transactions to the proposal. Note, the lane should only add transactions up to the
// max block space for the lane.
PrepareLane(
ctx sdk.Context,
proposal proposals.Proposal,
next PrepareLanesHandler,
) (proposals.Proposal, error)
// ProcessLane verifies this lane's portion of a proposed block. It inputs the current context,
// proposal, transactions that belong to this lane, and a function to call the next lane in the
// chain. This handler should update the context as needed and add transactions to the proposal.
// The entire process lane chain should end up constructing the same proposal as the prepare lane
// chain.
ProcessLane(
ctx sdk.Context,
proposal proposals.Proposal,
partialProposal [][]byte,
next ProcessLanesHandler,
) (proposals.Proposal, error)
// GetMaxBlockSpace returns the max block space for the lane as a relative percentage.
GetMaxBlockSpace() math.LegacyDec
// Name returns the name of the lane.
Name() string
// SetAnteHandler sets the lane's antehandler.
SetAnteHandler(antehander sdk.AnteHandler)
// SetIgnoreList sets the lanes that should be ignored by this lane.
SetIgnoreList(ignoreList []Lane)
// Match determines if a transaction belongs to this lane.
Match(ctx sdk.Context, tx sdk.Tx) bool
}
Lane defines an interface used for matching transactions to lanes, storing transactions, and constructing partial blocks.
type LaneMempool ¶
type LaneMempool interface {
sdkmempool.Mempool
// Compare determines the relative priority of two transactions belonging in the same lane. Compare
// will return -1 if this transaction has a lower priority than the other transaction, 0 if they have
// the same priority, and 1 if this transaction has a higher priority than the other transaction.
Compare(ctx sdk.Context, this, other sdk.Tx) (int, error)
// Contains returns true if the transaction is contained in the mempool.
Contains(tx sdk.Tx) bool
}
LaneMempool defines the interface a lane's mempool should implement. The basic API is the same as the sdk.Mempool, but it also includes a Compare function that is used to determine the relative priority of two transactions belonging in the same lane.
type LanedMempool ¶
type LanedMempool struct {
// contains filtered or unexported fields
}
LanedMempool defines the Block SDK mempool implementation. It contains a registry of lanes, which allows for customizable block proposal construction.
func (*LanedMempool) Contains ¶
func (m *LanedMempool) Contains(tx sdk.Tx) (contains bool)
Contains returns true if the transaction is contained in any of the lanes.
func (*LanedMempool) CountTx ¶
func (m *LanedMempool) CountTx() int
CountTx returns the total number of transactions in the mempool. This will be the sum of the number of transactions in each lane.
func (*LanedMempool) GetTxDistribution ¶
func (m *LanedMempool) GetTxDistribution() map[string]int
GetTxDistribution returns the number of transactions in each lane.
func (*LanedMempool) Insert ¶
Insert will insert a transaction into the mempool. It inserts the transaction into the first lane that it matches.
func (*LanedMempool) Registry ¶
func (m *LanedMempool) Registry() []Lane
Registry returns the mempool's lane registry.
func (*LanedMempool) Remove ¶
func (m *LanedMempool) Remove(tx sdk.Tx) (err error)
Remove removes a transaction from all of the lanes it is currently in.
func (*LanedMempool) Select ¶
func (m *LanedMempool) Select(_ context.Context, _ [][]byte) sdkmempool.Iterator
Insert returns a nil iterator.
TODO: - Determine if it even makes sense to return an iterator. What does that even mean in the context where you have multiple lanes? - Perhaps consider implementing and returning a no-op iterator?
func (*LanedMempool) ValidateBasic ¶
func (m *LanedMempool) ValidateBasic() error
ValidateBasic validates the mempools configuration. ValidateBasic ensures the following: - The sum of the lane max block space percentages is less than or equal to 1. - There is no unused block space.
type Mempool ¶
type Mempool interface {
sdkmempool.Mempool
// Registry returns the mempool's lane registry.
Registry() []Lane
// Contains returns the any of the lanes currently contain the transaction.
Contains(tx sdk.Tx) bool
// GetTxDistribution returns the number of transactions in each lane.
GetTxDistribution() map[string]int
}
Mempool defines the Block SDK mempool interface.
func NewLanedMempool ¶
NewLanedMempool returns a new Block SDK LanedMempool. The laned mempool is comprised of a registry of lanes. Each lane is responsible for selecting transactions according to its own selection logic. The lanes are ordered according to their priority. The first lane in the registry has the highest priority. Proposals are verified according to the order of the lanes in the registry. Each transaction should only belong in one lane but this is NOT enforced. To enforce that each transaction belong to a single lane, you must configure the ignore list of each lane to include all preceding lanes. Basic mempool API will attempt to insert, remove transactions from all lanes it belongs to. It is recommended, that mutex is set to true when creating the mempool. This will ensure that each transaction cannot be inserted into the lanes before it.
type PrepareLanesHandler ¶
type PrepareLanesHandler func(ctx sdk.Context, proposal proposals.Proposal) (proposals.Proposal, error)
PrepareLanesHandler wraps all of the lanes' PrepareLane function into a single chained function. You can think of it like an AnteHandler, but for preparing proposals in the context of lanes instead of modules.
func NoOpPrepareLanesHandler ¶
func NoOpPrepareLanesHandler() PrepareLanesHandler
NoOpPrepareLanesHandler returns a no-op prepare lanes handler. This should only be used for testing.
type ProcessLanesHandler ¶
type ProcessLanesHandler func(ctx sdk.Context, proposal proposals.Proposal) (proposals.Proposal, error)
ProcessLanesHandler wraps all of the lanes' ProcessLane functions into a single chained function. You can think of it like an AnteHandler, but for processing proposals in the context of lanes instead of modules.
func NoOpProcessLanesHandler ¶
func NoOpProcessLanesHandler() ProcessLanesHandler
NoOpProcessLanesHandler returns a no-op process lanes handler. This should only be used for testing.