Documentation
¶
Index ¶
- type BlockSpace
- func (bs BlockSpace) Add(other BlockSpace) BlockSpace
- func (bs BlockSpace) Gas() uint64
- func (bs BlockSpace) IsExceededBy(other BlockSpace) bool
- func (bs BlockSpace) IsReachedBy(other BlockSpace) bool
- func (bs BlockSpace) Scale(dec sdkmath.LegacyDec) (BlockSpace, error)
- func (bs BlockSpace) String() string
- func (bs BlockSpace) Sub(other BlockSpace) BlockSpace
- func (bs BlockSpace) TxBytes() uint64
- type Lane
- func (l *Lane) Contains(tx sdk.Tx) bool
- func (l *Lane) CountTx() int
- func (l *Lane) FillProposal(ctx sdk.Context, proposal *Proposal) (blockUsed BlockSpace, iterator sdkmempool.Iterator)
- func (l *Lane) FillProposalByIterator(proposal *Proposal, iterator sdkmempool.Iterator, limit BlockSpace) (blockUsed BlockSpace)
- func (l *Lane) Insert(ctx context.Context, tx sdk.Tx) error
- func (l *Lane) Match(ctx sdk.Context, tx sdk.Tx) bool
- func (l *Lane) Remove(tx sdk.Tx) error
- func (l *Lane) SetBlocked(blocked bool)
- type Mempool
- func (m *Mempool) Contains(tx sdk.Tx) (contains bool)
- func (m *Mempool) CountTx() int
- func (m *Mempool) GetLane(name string) *Lane
- func (m *Mempool) Insert(ctx context.Context, tx sdk.Tx) (err error)
- func (m *Mempool) PrepareProposal(ctx sdk.Context, proposal Proposal) (Proposal, error)
- func (m *Mempool) Remove(tx sdk.Tx) (err error)
- func (m *Mempool) Select(ctx context.Context, txs [][]byte) sdkmempool.Iterator
- type Proposal
- type ProposalHandler
- type TxMatchFn
- type TxWithInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockSpace ¶
type BlockSpace struct {
// contains filtered or unexported fields
}
BlockSpace defines the block space.
func NewBlockSpace ¶
func NewBlockSpace(txBytes uint64, gas uint64) BlockSpace
NewBlockSpace returns a new block space.
func (BlockSpace) Add ¶
func (bs BlockSpace) Add(other BlockSpace) BlockSpace
Add returns the sum of this BlockSpace and another BlockSpace.
func (BlockSpace) Gas ¶
func (bs BlockSpace) Gas() uint64
func (BlockSpace) IsExceededBy ¶
func (bs BlockSpace) IsExceededBy(other BlockSpace) bool
IsExceededBy returns true if 'other' usage has exceeded this BlockSpace's limits.
func (BlockSpace) IsReachedBy ¶
func (bs BlockSpace) IsReachedBy(other BlockSpace) bool
IsReachedBy returns true if 'other' usage has reached this BlockSpace's limits.
func (BlockSpace) Scale ¶
func (bs BlockSpace) Scale(dec sdkmath.LegacyDec) (BlockSpace, error)
Scale returns a new BlockSpace with txBytes and gas multiplied by a decimal.
func (BlockSpace) String ¶
func (bs BlockSpace) String() string
String returns a string representation of the BlockSpace.
func (BlockSpace) Sub ¶
func (bs BlockSpace) Sub(other BlockSpace) BlockSpace
Sub returns the difference between this BlockSpace and another BlockSpace. Ensures txBytes and gas never go below zero.
func (BlockSpace) TxBytes ¶
func (bs BlockSpace) TxBytes() uint64
type Lane ¶
type Lane struct {
// contains filtered or unexported fields
}
Lane defines a logical grouping of transactions within the mempool.
func NewLane ¶
func NewLane( logger log.Logger, txEncoder sdk.TxEncoder, name string, txMatchFn TxMatchFn, maxTransactionBlockRatio math.LegacyDec, maxLaneBlockRatio math.LegacyDec, mempool sdkmempool.Mempool, callbackAfterFillProposal func(isLaneLimitExceeded bool), ) *Lane
NewLane is a constructor for a lane.
func (*Lane) FillProposal ¶
func (l *Lane) FillProposal( ctx sdk.Context, proposal *Proposal, ) (blockUsed BlockSpace, iterator sdkmempool.Iterator)
FillProposal fills the proposal with transactions from the lane mempool with its own limit. It returns the total size and gas of the transactions added to the proposal. It also returns an iterator to the next transaction in the mempool.
func (*Lane) FillProposalByIterator ¶
func (l *Lane) FillProposalByIterator( proposal *Proposal, iterator sdkmempool.Iterator, limit BlockSpace, ) (blockUsed BlockSpace)
FillProposalByIterator fills the proposal with transactions from the lane mempool with the given iterator and limit. It returns the total size and gas of the transactions added to the proposal.
func (*Lane) SetBlocked ¶
SetBlocked sets the blocked flag to the given value.
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
Mempool implements the sdkmempool.Mempool interface and uses Lanes internally.
func NewMempool ¶
NewMempool returns a new mempool with the given lanes.
func (*Mempool) Contains ¶
Contains returns true if the transaction is contained in any of the lanes.
func (*Mempool) CountTx ¶
CountTx returns the total number of transactions across all lanes. Returns math.MaxInt if the total count would overflow.
func (*Mempool) Insert ¶
Insert will insert a transaction into the mempool. It inserts the transaction into the first lane that it matches.
func (*Mempool) PrepareProposal ¶
PrepareProposal divides the block gas limit among lanes (based on lane percentage), then calls each lane's FillProposal method. If leftover gas is important to you, you can implement a second pass or distribute leftover to subsequent lanes, etc.
type Proposal ¶
type Proposal struct {
// contains filtered or unexported fields
}
Proposal represents a block proposal under construction.
func NewProposal ¶
NewProposal returns a new empty proposal constrained by max block size and max gas limit.
func (*Proposal) Add ¶
func (p *Proposal) Add(txInfo TxWithInfo) error
Add attempts to add a transaction to the proposal, respecting size/gas limits.
func (*Proposal) Contains ¶
Contains returns true if the proposal already has a transaction with the given txHash.
func (*Proposal) GetRemainingBlockSpace ¶
func (p *Proposal) GetRemainingBlockSpace() BlockSpace
GetRemainingBlockSpace returns the remaining block space available for the proposal.
type ProposalHandler ¶
type ProposalHandler struct {
// contains filtered or unexported fields
}
ProposalHandler wraps ABCI++ PrepareProposal/ProcessProposal for the Mempool.
func NewProposalHandler ¶
func NewProposalHandler( logger log.Logger, txDecoder sdk.TxDecoder, mempool *Mempool, ) *ProposalHandler
NewProposalHandler returns a new ABCI++ proposal handler for the Mempool.
func (*ProposalHandler) PrepareProposalHandler ¶
func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler
PrepareProposalHandler builds the next block proposal from the Mempool.
func (*ProposalHandler) ProcessProposalHandler ¶
func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler
ProcessProposalHandler returns a no-op process proposal handler.
type TxWithInfo ¶
type TxWithInfo struct {
// Hash is the hex-encoded hash of the transaction.
Hash string
// BlockSpace is the block space used by the transaction.
BlockSpace BlockSpace
// TxBytes is the raw transaction bytes.
TxBytes []byte
}
TxWithInfo holds metadata required for a transaction to be included in a proposal.