base

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

README

Base Lane

Overview

The base lane is purposefully built to be a simple lane that can be extended (inherited) by other lanes. It provides the basic functionality that is required by all lanes with the option to override any of the methods.

The base lane implements the lane interface and provides a few critical methods that allow application developers to create a lane that has custom transaction ordering and execution logic. The most important things you need to know in order to build a custom lane are:

  • MatchHandler: This method is responsible for determining if a given transaction should be accepted by the lane.
  • PrepareLaneHandler: This method is responsible for reaping transactions from the mempool, validating them, re-ordering (if necessary), and returning them to be included in a block proposal.
  • ProcessLaneHandler: This method is responsible verifying the matched transactions that were included in a block proposal.
  • LaneMempool: This allows developers to have the freedom to implement their own mempools with custom transaction ordering logic.
  • LaneConfig: This allows developers to customize how the lane behaves in terms of max block space, max transaction count, and more.

MatchHandler

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. The function signature is as follows:

MatchHandler func(ctx sdk.Context, tx sdk.Tx) bool

To create a custom lane with a custom MatchHandler, you must implement this function and pass it into the constructor for the base lane. For example, the free lane inherits all the base lane functionality but overrides the MatchHandler to only accept staking related transactions.

// DefaultMatchHandler returns the default match handler for the free lane. The
// default implementation matches transactions that are staking related. In particular,
// any transaction that is a MsgDelegate, MsgBeginRedelegate, or MsgCancelUnbondingDelegation.
func DefaultMatchHandler() base.MatchHandler {
	return func(ctx sdk.Context, tx sdk.Tx) bool {
		for _, msg := range tx.GetMsgs() {
			switch msg.(type) {
			case *types.MsgDelegate:
				return true
			case *types.MsgBeginRedelegate:
				return true
			case *types.MsgCancelUnbondingDelegation:
				return true
			}
		}

		return false
	}
}

The default MatchHandler is implemented in the base lane and matches all transactions.

PrepareLaneHandler

The PrepareLaneHandler is responsible for reaping transactions from the mempool, validating them, re-ordering (if necessary), and returning them to be included in a block proposal. If any of the transactions were invalid, it should return them alongside the transactions it wants to include in the proposal. The invalid transactions will subsequently be removed from the lane's mempool. The function signature is as follows:

PrepareLaneHandler func(
    ctx sdk.Context,
    proposal proposals.Proposal,
    limit proposals.LaneLimits,
) (txsToInclude []sdk.Tx, txsToRemove []sdk.Tx, err error)

To create a custom lane with a custom PrepareLaneHandler, you must implement this function and set it on the lane after it has been created. Please visit the MEV lane's PrepareLaneHandler for an example of how to implement this function.

The default PrepareLaneHandler is implemented in the base lane. It reaps transactions from the mempool, validates them, ensures that the lane's block space limit is not exceeded, and returns the transactions to be included in the block and the ones that need to be removed.

ProcessLaneHandler

The ProcessLaneHandler is responsible for verifying the transactions that belong to a given lane that were included in a block proposal and returning those that did not to the next lane. The function signature is as follows:

ProcessLaneHandler func(ctx sdk.Context, partialProposal []sdk.Tx) (
    txsFromLane []sdk.Tx,
    remainingTxs []sdk.Tx,
    err error,
)

Note that block proposals built using the Block SDK contain contiguous sections of transactions in the block that belong to a given lane, to read more about how proposals are constructed relative to other lanes, please visit the abci section. As such, a given lane will recieve some transactions in (partialProposal) that belong to it and some that do not. The transactions that belong to it must be contiguous from the start, and the transactions that do not belong to it must be contiguous from the end. The lane must return the transactions that belong to it and the transactions that do not belong to it. The transactions that do not belong to it will be passed to the next lane in the proposal. The default ProcessLaneHandler is implemented in the base lane. It verifies the transactions that belong to the lane and returns them alongside the transactions that do not belong to the lane.

Please visit the MEV lane's ProcessLaneHandler for an example of how to implement a custom handler.

LaneMempool

The lane mempool is the data structure that is responsible for storing transactions that belong to a given lane, before they are included in a block proposal. The lane mempool input's a TxPriority object that allows developers to customize how they want to order transactions within their mempool. Additionally, it also accepts a signer extrator adapter that allows for custom signature schemes to be used (although the default covers Cosmos SDK transactions). To read more about the signer extractor adapter, please visit the signer extractor section.

TxPriority

The TxPriority object is responsible for ordering transactions within the mempool. The definition of the TxPriority object is as follows:

// TxPriority defines a type that is used to retrieve and compare transaction
// priorities. Priorities must be comparable.
TxPriority[C comparable] struct {
    // GetTxPriority returns the priority of the transaction. A priority must be
    // comparable via Compare.
    GetTxPriority func(ctx context.Context, tx sdk.Tx) C

    // CompareTxPriority compares two transaction priorities. The result should be
    // 0 if a == b, -1 if a < b, and +1 if a > b.
    Compare func(a, b C) int

    // MinValue defines the minimum priority value, e.g. MinInt64. This value is
    // used when instantiating a new iterator and comparing weights.
    MinValue C
}

The default implementation can be found in the base lane. It orders transactions by their gas price in descending order. The TxPriority object is passed into the lane mempool constructor. Please visit the MEV lane's TxPriority for an example of how to implement a custom TxPriority.

LaneConfig

The lane config is the object that is responsible for configuring the lane. It allows developers to customize how the lane behaves in terms of max block space, max transaction count, and more. The definition of the LaneConfig object is as follows:

// LaneConfig defines the basic configurations needed for a lane.
type LaneConfig struct {
	Logger      log.Logger
	TxEncoder   sdk.TxEncoder
	TxDecoder   sdk.TxDecoder
	AnteHandler sdk.AnteHandler

	// SignerExtractor defines the interface used for extracting the expected signers of a transaction
	// from the transaction.
	SignerExtractor signer_extraction.Adapter

	// MaxBlockSpace defines the relative percentage of block space that can be
	// used by this lane. NOTE: If this is set to zero, then there is no limit
	// on the number of transactions that can be included in the block for this
	// lane (up to maxTxBytes as provided by the request). This is useful for the default lane.
	MaxBlockSpace math.LegacyDec

	// MaxTxs sets the maximum number of transactions allowed in the mempool with
	// the semantics:
	// - if MaxTx == 0, there is no cap on the number of transactions in the mempool
	// - if MaxTx > 0, the mempool will cap the number of transactions it stores,
	//   and will prioritize transactions by their priority and sender-nonce
	//   (sequence number) when evicting transactions.
	// - if MaxTx < 0, `Insert` is a no-op.
	MaxTxs int
}

Each lane must define its own custom LaneConfig in order to be properly instantiated. Please visit app.go for an example of how to implement a custom LaneConfig.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmpty

func IsEmpty[C comparable](mempool sdkmempool.Mempool) error

Types

type BaseLane

type BaseLane struct {

	// LaneMempool is the mempool that is responsible for storing transactions
	// that are waiting to be processed.
	block.LaneMempool
	// contains filtered or unexported fields
}

BaseLane is a generic implementation of a lane. It is meant to be used as a base for other lanes to be built on top of. It provides a default implementation of the MatchHandler, PrepareLaneHandler, ProcessLaneHandler, and CheckOrderHandler. To extend this lane, you must either utilize the default handlers or construct your own that you pass into the base/setters.

func NewBaseLane

func NewBaseLane(
	cfg LaneConfig,
	laneName string,
	options ...LaneOption,
) (*BaseLane, error)

NewBaseLane returns a new lane base. When creating this lane, the type of the lane must be specified. The type of the lane is directly associated with the type of the mempool that is used to store transactions that are waiting to be processed.

func (*BaseLane) GetMaxBlockSpace

func (l *BaseLane) GetMaxBlockSpace() math.LegacyDec

GetMaxBlockSpace returns the maximum amount of block space that the lane is allowed to consume as a percentage of the total block space.

func (*BaseLane) GetTxInfo added in v1.3.0

func (l *BaseLane) GetTxInfo(ctx sdk.Context, tx sdk.Tx) (utils.TxWithInfo, error)

GetTxInfo returns various information about the transaction that belongs to the lane including its priority, signer's, sequence number, size and more.

func (*BaseLane) Logger

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

Logger returns the logger for the lane.

func (*BaseLane) Match

func (l *BaseLane) Match(ctx sdk.Context, tx sdk.Tx) bool

Match returns true if the transaction should be processed by this lane. This function first determines if the transaction matches the lane and then checks if the transaction is on the ignore list. If the transaction is on the ignore list, it returns false.

func (*BaseLane) Name

func (l *BaseLane) Name() string

Name returns the name of the lane.

func (*BaseLane) PrepareLane

func (l *BaseLane) PrepareLane(
	ctx sdk.Context,
	proposal proposals.Proposal,
	next block.PrepareLanesHandler,
) (proposals.Proposal, error)

PrepareLane will prepare a partial proposal for the lane. It will select transactions from the lane respecting the selection logic of the prepareLaneHandler. It will then update the partial proposal with the selected transactions. If the proposal is unable to be updated, we return an error. The proposal will only be modified if it passes all of the invariant checks.

func (*BaseLane) ProcessLane

func (l *BaseLane) ProcessLane(
	ctx sdk.Context,
	proposal proposals.Proposal,
	txs []sdk.Tx,
	next block.ProcessLanesHandler,
) (proposals.Proposal, error)

ProcessLane verifies that the transactions included in the block proposal are valid respecting the verification logic of the lane (processLaneHandler). If any of the transactions are invalid, we return an error. If all of the transactions are valid, we return the updated proposal.

func (*BaseLane) TxDecoder

func (l *BaseLane) TxDecoder() sdk.TxDecoder

TxDecoder returns the tx decoder for the lane.

func (*BaseLane) TxEncoder

func (l *BaseLane) TxEncoder() sdk.TxEncoder

TxEncoder returns the tx encoder for the lane.

func (*BaseLane) ValidateBasic

func (l *BaseLane) ValidateBasic() error

ValidateBasic ensures that the lane was constructed properly. In the case that the lane was not constructed with proper handlers, default handlers are set.

func (*BaseLane) VerifyNoMatches added in v1.3.0

func (l *BaseLane) VerifyNoMatches(ctx sdk.Context, txs []sdk.Tx) error

VerifyNoMatches returns an error if any of the transactions match the lane.

func (*BaseLane) VerifyTx added in v1.1.0

func (l *BaseLane) VerifyTx(ctx sdk.Context, tx sdk.Tx, simulate bool) error

VerifyTx verifies that the transaction is valid respecting the ante verification logic of of the antehandler chain.

func (*BaseLane) WithOptions added in v1.3.0

func (l *BaseLane) WithOptions(options ...LaneOption) *BaseLane

WithOptions returns a new lane with the given options.

type DefaultProposalHandler added in v1.3.0

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

DefaultProposalHandler returns a default implementation of the PrepareLaneHandler and ProcessLaneHandler.

func NewDefaultProposalHandler added in v1.3.0

func NewDefaultProposalHandler(lane *BaseLane) *DefaultProposalHandler

NewDefaultProposalHandler returns a new default proposal handler.

func (*DefaultProposalHandler) PrepareLaneHandler added in v1.3.0

func (h *DefaultProposalHandler) PrepareLaneHandler() PrepareLaneHandler

DefaultPrepareLaneHandler returns a default implementation of the PrepareLaneHandler. It selects all transactions in the mempool that are valid and not already in the partial proposal. It will continue to reap transactions until the maximum blockspace/gas for this lane has been reached. Additionally, any transactions that are invalid will be returned.

func (*DefaultProposalHandler) ProcessLaneHandler added in v1.3.0

func (h *DefaultProposalHandler) ProcessLaneHandler() ProcessLaneHandler

DefaultProcessLaneHandler returns a default implementation of the ProcessLaneHandler. It verifies the following invariants:

  1. Transactions belonging to the lane must be contiguous from the beginning of the partial proposal.
  2. Transactions that do not belong to the lane must be contiguous from the end of the partial proposal.
  3. Transactions must be ordered respecting the priority defined by the lane (e.g. gas price).
  4. Transactions must be valid according to the verification logic of the lane.

type LaneConfig

type LaneConfig struct {
	Logger      log.Logger
	TxEncoder   sdk.TxEncoder
	TxDecoder   sdk.TxDecoder
	AnteHandler sdk.AnteHandler

	// SignerExtractor defines the interface used for extracting the expected signers of a transaction
	// from the transaction.
	SignerExtractor signer_extraction.Adapter

	// MaxBlockSpace defines the relative percentage of block space that can be
	// used by this lane. NOTE: If this is set to zero, then there is no limit
	// on the number of transactions that can be included in the block for this
	// lane (up to maxTxBytes as provided by the request). This is useful for the default lane.
	MaxBlockSpace math.LegacyDec

	// MaxTxs sets the maximum number of transactions allowed in the mempool with
	// the semantics:
	// - if MaxTx == 0, there is no cap on the number of transactions in the mempool
	// - if MaxTx > 0, the mempool will cap the number of transactions it stores,
	//   and will prioritize transactions by their priority and sender-nonce
	//   (sequence number) when evicting transactions.
	// - if MaxTx < 0, `Insert` is a no-op.
	MaxTxs int
}

LaneConfig defines the basic configurations needed for a lane.

func NewLaneConfig

func NewLaneConfig(
	logger log.Logger,
	txEncoder sdk.TxEncoder,
	txDecoder sdk.TxDecoder,
	anteHandler sdk.AnteHandler,
	signerExtractor signer_extraction.Adapter,
	maxBlockSpace math.LegacyDec,
) LaneConfig

NewLaneConfig returns a new LaneConfig. This will be embedded in a lane.

func (*LaneConfig) ValidateBasic

func (c *LaneConfig) ValidateBasic() error

ValidateBasic validates the lane configuration.

type LaneOption added in v1.3.0

type LaneOption func(*BaseLane)

LaneOption defines a function that can be used to set options on a lane.

func WithAnteHandler added in v1.3.0

func WithAnteHandler(anteHandler sdk.AnteHandler) LaneOption

WithAnteHandler sets the ante handler for the lane.

func WithMatchHandler added in v1.3.0

func WithMatchHandler(matchHandler MatchHandler) LaneOption

WithMatchHandler sets the match handler for the lane. This handler is called when a new transaction is being submitted to the lane and the lane needs to determine if the transaction should be processed by the lane.

func WithMempool added in v1.3.0

func WithMempool(mempool block.LaneMempool) LaneOption

WithMempool sets the mempool for the lane. This mempool is used to store transactions that are waiting to be processed.

func WithMempoolConfigs added in v1.3.0

func WithMempoolConfigs[C comparable](cfg LaneConfig, txPriority TxPriority[C]) LaneOption

WithMempoolConfigs sets the mempool for the lane with the given lane config and TxPriority struct. This mempool is used to store transactions that are waiting to be processed.

func WithPrepareLaneHandler added in v1.3.0

func WithPrepareLaneHandler(prepareLaneHandler PrepareLaneHandler) LaneOption

WithPrepareLaneHandler sets the prepare lane handler for the lane. This handler is called when a new proposal is being requested and the lane needs to submit transactions it wants included in the block.

func WithProcessLaneHandler added in v1.3.0

func WithProcessLaneHandler(processLaneHandler ProcessLaneHandler) LaneOption

WithProcessLaneHandler sets the process lane handler for the lane. This handler is called when a new proposal is being verified and the lane needs to verify that the transactions included in the proposal are valid respecting the verification logic of the lane.

type MatchHandler

type MatchHandler func(ctx sdk.Context, tx sdk.Tx) bool

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.

func DefaultMatchHandler

func DefaultMatchHandler() MatchHandler

DefaultMatchHandler returns a default implementation of the MatchHandler. It matches all transactions.

func NewMatchHandler added in v1.3.0

func NewMatchHandler(mh MatchHandler, ignoreMHs ...MatchHandler) MatchHandler

NewMatchHandler returns a match handler that matches transactions that match the lane and do not match with any of the provided match handlers. In the context of building an application, you would want to use this to ignore the match handlers of other lanes in the application.

type Mempool

type Mempool[C comparable] struct {
	// contains filtered or unexported fields
}

Mempool defines a mempool that orders transactions based on the txPriority. The mempool is a wrapper on top of the SDK's Priority Nonce mempool. It include's additional helper functions that allow users to determine if a transaction is already in the mempool and to compare the priority of two transactions.

func NewMempool

func NewMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, extractor signer_extraction.Adapter, maxTx int) *Mempool[C]

NewMempool returns a new Mempool.

func (*Mempool[C]) Compare

func (cm *Mempool[C]) Compare(ctx sdk.Context, this sdk.Tx, other sdk.Tx) (int, error)

Compare determines the relative priority of two transactions belonging in the same lane. There are two cases to consider:

  1. The transactions have the same signer. In this case, we compare the sequence numbers.
  2. The transactions have different signers. In this case, we compare the priorities of the transactions.

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.

func (*Mempool[C]) Contains

func (cm *Mempool[C]) Contains(tx sdk.Tx) bool

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

func (*Mempool[C]) CountTx

func (cm *Mempool[C]) CountTx() int

CountTx returns the number of transactions in the mempool.

func (*Mempool[C]) Insert

func (cm *Mempool[C]) Insert(ctx context.Context, tx sdk.Tx) error

Insert inserts a transaction into the mempool.

func (*Mempool[C]) Priority added in v1.3.0

func (cm *Mempool[C]) Priority(ctx sdk.Context, tx sdk.Tx) any

Priority returns the priority of the transaction.

func (*Mempool[C]) Remove

func (cm *Mempool[C]) Remove(tx sdk.Tx) error

Remove removes a transaction from the mempool.

func (*Mempool[C]) Select

func (cm *Mempool[C]) Select(ctx context.Context, txs [][]byte) sdkmempool.Iterator

Select returns an iterator of all transactions in the mempool. NOTE: If you remove a transaction from the mempool while iterating over the transactions, the iterator will not be aware of the removal and will continue to iterate over the removed transaction. Be sure to reset the iterator if you remove a transaction.

type PrepareLaneHandler

type PrepareLaneHandler func(
	ctx sdk.Context,
	proposal proposals.Proposal,
	limit proposals.LaneLimits,
) (txsToInclude []sdk.Tx, txsToRemove []sdk.Tx, err error)

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.

func NoOpPrepareLaneHandler

func NoOpPrepareLaneHandler() PrepareLaneHandler

NoOpPrepareLaneHandler returns a no-op prepare lane handler. This should only be used for testing.

func PanicPrepareLaneHandler

func PanicPrepareLaneHandler() PrepareLaneHandler

PanicPrepareLaneHandler returns a prepare lane handler that panics. This should only be used for testing.

type PriorityNonceIterator

type PriorityNonceIterator[C comparable] struct {
	// contains filtered or unexported fields
}

PriorityNonceIterator defines an iterator that is used for mempool iteration on Select().

func (*PriorityNonceIterator[C]) Next

func (i *PriorityNonceIterator[C]) Next() sdkmempool.Iterator

func (*PriorityNonceIterator[C]) Tx

func (i *PriorityNonceIterator[C]) Tx() sdk.Tx

type PriorityNonceMempool

type PriorityNonceMempool[C comparable] struct {
	// contains filtered or unexported fields
}

PriorityNonceMempool is a mempool implementation that stores txs in a partially ordered set by 2 dimensions: priority, and sender-nonce (sequence number). Internally it uses one priority ordered skip list and one skip list per sender ordered by sender-nonce (sequence number). When there are multiple txs from the same sender, they are not always comparable by priority to other sender txs and must be partially ordered by both sender-nonce and priority.

func DefaultPriorityMempool

func DefaultPriorityMempool(extractor signer_extraction.DefaultAdapter) *PriorityNonceMempool[int64]

DefaultPriorityMempool returns a priorityNonceMempool with no options.

func NewPriorityMempool

func NewPriorityMempool[C comparable](cfg PriorityNonceMempoolConfig[C], extractor signer_extraction.Adapter) *PriorityNonceMempool[C]

NewPriorityMempool returns the SDK's default mempool implementation which returns txs in a partial order by 2 dimensions; priority, and sender-nonce.

func (*PriorityNonceMempool[C]) CountTx

func (mp *PriorityNonceMempool[C]) CountTx() int

CountTx returns the number of transactions in the mempool.

func (*PriorityNonceMempool[C]) Insert

func (mp *PriorityNonceMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error

Insert attempts to insert a Tx into the app-side mempool in O(log n) time, returning an error if unsuccessful. Sender and nonce are derived from the transaction's first signature.

Transactions are unique by sender and nonce. Inserting a duplicate tx is an O(log n) no-op.

Inserting a duplicate tx with a different priority overwrites the existing tx, changing the total order of the mempool.

func (*PriorityNonceMempool[C]) NextSenderTx

func (mp *PriorityNonceMempool[C]) NextSenderTx(sender string) sdk.Tx

NextSenderTx returns the next transaction for a given sender by nonce order, i.e. the next valid transaction for the sender. If no such transaction exists, nil will be returned.

func (*PriorityNonceMempool[C]) Remove

func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error

Remove removes a transaction from the mempool in O(log n) time, returning an error if unsuccessful.

func (*PriorityNonceMempool[C]) Select

func (mp *PriorityNonceMempool[C]) Select(_ context.Context, _ [][]byte) sdkmempool.Iterator

Select returns a set of transactions from the mempool, ordered by priority and sender-nonce in O(n) time. The passed in list of transactions are ignored. This is a readonly operation, the mempool is not modified.

The maxBytes parameter defines the maximum number of bytes of transactions to return.

type PriorityNonceMempoolConfig

type PriorityNonceMempoolConfig[C comparable] struct {
	// TxPriority defines the transaction priority and comparator.
	TxPriority TxPriority[C]

	// OnRead is a callback to be called when a tx is read from the mempool.
	OnRead func(tx sdk.Tx)

	// TxReplacement is a callback to be called when duplicated transaction nonce
	// detected during mempool insert. An application can define a transaction
	// replacement rule based on tx priority or certain transaction fields.
	TxReplacement func(op, np C, oTx, nTx sdk.Tx) bool

	// MaxTx sets the maximum number of transactions allowed in the mempool with
	// the semantics:
	// - if MaxTx == 0, there is no cap on the number of transactions in the mempool
	// - if MaxTx > 0, the mempool will cap the number of transactions it stores,
	//   and will prioritize transactions by their priority and sender-nonce
	//   (sequence number) when evicting transactions.
	// - if MaxTx < 0, `Insert` is a no-op.
	MaxTx int
}

PriorityNonceMempoolConfig defines the configuration used to configure the PriorityNonceMempool.

func DefaultPriorityNonceMempoolConfig

func DefaultPriorityNonceMempoolConfig() PriorityNonceMempoolConfig[int64]

type ProcessLaneHandler

type ProcessLaneHandler func(ctx sdk.Context, partialProposal []sdk.Tx) (
	txsFromLane []sdk.Tx,
	remainingTxs []sdk.Tx,
	err error,
)

ProcessLaneHandler is responsible for processing transactions that are included in a block and belong to a given lane. The handler must return the transactions that were successfully processed and the transactions that it cannot process because they belong to a different lane.

func NoOpProcessLaneHandler

func NoOpProcessLaneHandler() ProcessLaneHandler

NoOpProcessLaneHandler returns a no-op process lane handler. This should only be used for testing.

func PanicProcessLaneHandler

func PanicProcessLaneHandler() ProcessLaneHandler

PanicProcessLanesHandler returns a process lanes handler that panics. This should only be used for testing.

type TxPriority

type TxPriority[C comparable] struct {
	// GetTxPriority returns the priority of the transaction. A priority must be
	// comparable via Compare.
	GetTxPriority func(ctx context.Context, tx sdk.Tx) C

	// CompareTxPriority compares two transaction priorities. The result should be
	// 0 if a == b, -1 if a < b, and +1 if a > b.
	Compare func(a, b C) int

	// MinValue defines the minimum priority value, e.g. MinInt64. This value is
	// used when instantiating a new iterator and comparing weights.
	MinValue C
}

TxPriority defines a type that is used to retrieve and compare transaction priorities. Priorities must be comparable.

func DefaultTxPriority

func DefaultTxPriority() TxPriority[int]

DefaultTxPriority

func NewDefaultTxPriority

func NewDefaultTxPriority() TxPriority[int64]

NewDefaultTxPriority returns a TxPriority comparator using ctx.Priority as the defining transaction priority.

Jump to

Keyboard shortcuts

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