txpool

package
v0.0.0-...-77dcbbd Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package txpool provides transaction pool which maintain transactions by nonce asc and fee desc order.

Index

Constants

View Source
const (
	EventTransactionNew          = "EventTransactionNew"
	EventTransactionAnnouncement = "EventTransactionAnnouncement"
)
View Source
const (
	RPCEventPostTransactionAnnouncement = "postTransactionsAnnouncement"
	RPCEndpointGetTransactions          = "getTransactions"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ABI

type ABI interface {
	VerifyTransaction(req *labi.VerifyTransactionRequest) (*labi.VerifyTransactionResponse, error)
}

type DatabaseReader

type DatabaseReader interface {
	Get(key []byte) ([]byte, bool)
}

type EventNewTransactionAnnouncementMessage

type EventNewTransactionAnnouncementMessage struct {
	TransactionIDs []codec.Hex `json:"transactionIDs"`
}

type EventNewTransactionMessage

type EventNewTransactionMessage struct {
	Transaction *blockchain.Transaction `json:"transaction"`
}

type FeeMaxHeap

type FeeMaxHeap []*TransactionWithFeePriority

func (FeeMaxHeap) Len

func (h FeeMaxHeap) Len() int

func (FeeMaxHeap) Less

func (h FeeMaxHeap) Less(i, j int) bool

func (*FeeMaxHeap) Pop

func (h *FeeMaxHeap) Pop() interface{}

func (*FeeMaxHeap) Push

func (h *FeeMaxHeap) Push(x interface{})

func (FeeMaxHeap) Swap

func (h FeeMaxHeap) Swap(i, j int)

type FeeMinHeap

type FeeMinHeap []*TransactionWithFeePriority

func (FeeMinHeap) Len

func (h FeeMinHeap) Len() int

func (FeeMinHeap) Less

func (h FeeMinHeap) Less(i, j int) bool

func (*FeeMinHeap) Pop

func (h *FeeMinHeap) Pop() interface{}

func (*FeeMinHeap) Push

func (h *FeeMinHeap) Push(x interface{})

func (FeeMinHeap) Swap

func (h FeeMinHeap) Swap(i, j int)

type GetTransactionsResponse

type GetTransactionsResponse struct {
	Transactions []*blockchain.Transaction `json:"transactions" fieldNumber:"1"`
}

func (*GetTransactionsResponse) Decode

func (e *GetTransactionsResponse) Decode(data []byte) error

func (*GetTransactionsResponse) DecodeFromReader

func (e *GetTransactionsResponse) DecodeFromReader(reader *codec.Reader) error

func (*GetTransactionsResponse) DecodeStrict

func (e *GetTransactionsResponse) DecodeStrict(data []byte) error

func (*GetTransactionsResponse) DecodeStrictFromReader

func (e *GetTransactionsResponse) DecodeStrictFromReader(reader *codec.Reader) error

func (*GetTransactionsResponse) Encode

func (e *GetTransactionsResponse) Encode() []byte

func (*GetTransactionsResponse) MustDecode

func (e *GetTransactionsResponse) MustDecode(data []byte)

type NonceMinHeap

type NonceMinHeap []uint64

func (NonceMinHeap) Len

func (h NonceMinHeap) Len() int

func (NonceMinHeap) Less

func (h NonceMinHeap) Less(i, j int) bool

func (*NonceMinHeap) Pop

func (h *NonceMinHeap) Pop() interface{}

func (*NonceMinHeap) Push

func (h *NonceMinHeap) Push(x interface{})

func (NonceMinHeap) Swap

func (h NonceMinHeap) Swap(i, j int)

type TransactionPool

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

func NewTransactionPool

func NewTransactionPool(cfg *TransactionPoolConfig) *TransactionPool

func (*TransactionPool) Add

func (*TransactionPool) End

func (t *TransactionPool) End()

func (*TransactionPool) Get

func (t *TransactionPool) Get(id []byte) (*blockchain.Transaction, bool)

func (*TransactionPool) GetAll

func (t *TransactionPool) GetAll() []*blockchain.Transaction

func (*TransactionPool) GetProcessable

func (t *TransactionPool) GetProcessable() []*blockchain.Transaction

func (*TransactionPool) HandleRPCEndpointGetTransaction

func (t *TransactionPool) HandleRPCEndpointGetTransaction(w p2p.ResponseWriter, r *p2p.Request)

func (*TransactionPool) Init

func (t *TransactionPool) Init(
	ctx context.Context,
	logger log.Logger,
	database *db.DB,
	chain *blockchain.Chain,
	conn p2pConnection,
	abi ABI,
) error

func (*TransactionPool) Remove

func (t *TransactionPool) Remove(id []byte) bool

func (*TransactionPool) Start

func (t *TransactionPool) Start()

func (*TransactionPool) Subscribe

func (t *TransactionPool) Subscribe(topic string) <-chan interface{}

type TransactionPoolConfig

type TransactionPoolConfig struct {
	MaxTransactions             int    `json:"maxTransactions"`
	MaxTransactionsPerAccount   int    `json:"maxTransactionsPerAccount"`
	TransactionExpiryTime       int    `json:"transactionExpiryTime"`
	MinEntranceFeePriority      uint64 `json:"minEntranceFeePriority,string"`
	MinReplacementFeeDifference uint64 `json:"minReplacementFeeDifference,string"`
}

func (*TransactionPoolConfig) SetDefault

func (c *TransactionPoolConfig) SetDefault()

type TransactionWithFeePriority

type TransactionWithFeePriority struct {
	*blockchain.Transaction
	FeePriority uint64
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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