base

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LaneName defines the name of the default lane.
	LaneName = "default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLane

type DefaultLane struct {
	// Mempool defines the mempool for the lane.
	Mempool

	// LaneConfig defines the base lane configuration.
	Cfg blockbuster.BaseLaneConfig
}

DefaultLane defines a default lane implementation. The default lane orders transactions by the sdk.Context priority. The default lane will accept any transaction that is not a part of the lane's IgnoreList. By default, the IgnoreList is empty and the default lane will accept any transaction. The default lane on its own implements the same functionality as the pre v0.47.0 tendermint mempool and proposal handlers.

func NewDefaultLane

func NewDefaultLane(cfg blockbuster.BaseLaneConfig) *DefaultLane

NewDefaultLane returns a new default lane.

func (*DefaultLane) GetIgnoreList

func (l *DefaultLane) GetIgnoreList() []blockbuster.Lane

GetIgnoreList returns the lane's ignore list.

func (*DefaultLane) GetMaxBlockSpace

func (l *DefaultLane) GetMaxBlockSpace() sdk.Dec

GetMaxBlockSpace returns the maximum block space for the lane as a relative percentage.

func (*DefaultLane) Logger

func (l *DefaultLane) Logger() log.Logger

Logger returns the lane's logger.

func (*DefaultLane) Match

func (l *DefaultLane) Match(tx sdk.Tx) bool

Match returns true if the transaction belongs to this lane. Since this is the default lane, it always returns true except for transactions that belong to lanes in the ignore list.

func (*DefaultLane) Name

func (l *DefaultLane) Name() string

Name returns the name of the lane.

func (*DefaultLane) PrepareLane

func (l *DefaultLane) PrepareLane(
	ctx sdk.Context,
	proposal blockbuster.BlockProposal,
	maxTxBytes int64,
	next blockbuster.PrepareLanesHandler,
) (blockbuster.BlockProposal, error)

PrepareLane will prepare a partial proposal for the default lane. It will select and include all valid transactions in the mempool that are not already in the partial proposal. The default lane orders transactions by the sdk.Context priority.

func (*DefaultLane) ProcessLane

func (l *DefaultLane) ProcessLane(ctx sdk.Context, txs []sdk.Tx, next blockbuster.ProcessLanesHandler) (sdk.Context, error)

ProcessLane verifies the default lane's portion of a block proposal. Since the default lane's ProcessLaneBasic function ensures that all of the default transactions are in the correct order, we only need to verify the contiguous set of transactions that match to the default lane.

func (*DefaultLane) ProcessLaneBasic

func (l *DefaultLane) ProcessLaneBasic(txs []sdk.Tx) error

transactions that belong to this lane are not misplaced in the block proposal i.e. the proposal only contains contiguous transactions that belong to this lane - there can be no interleaving of transactions from other lanes.

func (*DefaultLane) SetAnteHandler

func (l *DefaultLane) SetAnteHandler(anteHandler sdk.AnteHandler)

SetAnteHandler sets the lane's antehandler.

func (*DefaultLane) VerifyTx

func (l *DefaultLane) VerifyTx(ctx sdk.Context, tx sdk.Tx) error

VerifyTx does basic verification of the transaction using the ante handler.

type DefaultMempool

type DefaultMempool struct {
	// contains filtered or unexported fields
}

DefaultMempool defines the most basic mempool. It can be seen as an extension of an SDK PriorityNonceMempool, i.e. a mempool that supports <sender, nonce> two-dimensional priority ordering, with the additional support of prioritizing and indexing transactions.

func NewDefaultMempool

func NewDefaultMempool(txEncoder sdk.TxEncoder) *DefaultMempool

NewDefaultMempool returns a new default mempool instance. The default mempool orders transactions by the sdk.Context priority.

func (*DefaultMempool) Contains

func (am *DefaultMempool) Contains(tx sdk.Tx) (bool, error)

Contains returns true if the transaction is contained in the mempool.

func (*DefaultMempool) CountTx

func (am *DefaultMempool) CountTx() int

func (*DefaultMempool) Insert

func (am *DefaultMempool) Insert(ctx context.Context, tx sdk.Tx) error

Insert inserts a transaction into the mempool based on the transaction type (normal or keyshare).

func (*DefaultMempool) Remove

func (am *DefaultMempool) Remove(tx sdk.Tx) error

Remove removes a transaction from the mempool based on the transaction type (normal or keyshare).

func (*DefaultMempool) Select

func (am *DefaultMempool) Select(ctx context.Context, txs [][]byte) sdkmempool.Iterator

type Mempool

type Mempool interface {
	sdkmempool.Mempool

	// Contains returns true if the transaction is contained in the mempool.
	Contains(tx sdk.Tx) (bool, error)
}

Mempool defines the interface of the default mempool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL