Documentation ¶
Overview ¶
Package bridgepool implements a pool of transactions generated by RemoteBackend.
Source files ¶
Each file provides the following features.
- bridge_tx_journal.go : logs transactions generated by SubBridge to allow non-executed ones to survive node restarts.
- bridge_tx_pool.go : contains transactions generated by SendTransaction function of RemoteBackend.
- sorted_map_list.go : implements a nonce-sorted item maps.
Index ¶
- Constants
- Variables
- type BridgeTxPool
- func (pool *BridgeTxPool) AddLocal(tx *types.Transaction) error
- func (pool *BridgeTxPool) AddLocals(txs []*types.Transaction) []error
- func (pool *BridgeTxPool) Content() map[common.Address]types.Transactions
- func (pool *BridgeTxPool) Get(hash common.Hash) *types.Transaction
- func (pool *BridgeTxPool) GetMaxTxNonce(from *common.Address) uint64
- func (pool *BridgeTxPool) GetTx(txHash common.Hash) (*types.Transaction, error)
- func (pool *BridgeTxPool) Pending() map[common.Address]types.Transactions
- func (pool *BridgeTxPool) PendingTxHashesByAddress(from *common.Address, limit int) []common.Hash
- func (pool *BridgeTxPool) PendingTxsByAddress(from *common.Address, limit int) types.Transactions
- func (pool *BridgeTxPool) Remove(txs types.Transactions) []error
- func (pool *BridgeTxPool) RemoveTx(tx *types.Transaction) error
- func (pool *BridgeTxPool) SetEIP155Signer(chainID *big.Int)
- func (pool *BridgeTxPool) Stats() int
- func (pool *BridgeTxPool) Stop()
- type BridgeTxPoolConfig
- type DevNull
- type ItemSortedMap
- func (m *ItemSortedMap) Exist(nonce uint64) bool
- func (m *ItemSortedMap) Filter(filter func(interface{}) bool) items
- func (m *ItemSortedMap) Flatten() items
- func (m *ItemSortedMap) FlattenByCount(count int) items
- func (m *ItemSortedMap) Forward(threshold uint64) items
- func (m *ItemSortedMap) Get(nonce uint64) itemWithNonce
- func (m *ItemSortedMap) Len() int
- func (m *ItemSortedMap) Pop(count int) items
- func (m *ItemSortedMap) Put(event itemWithNonce) error
- func (m *ItemSortedMap) Ready(start uint64) items
- func (m *ItemSortedMap) Remove(nonce uint64) bool
Constants ¶
const (
UnlimitedItemSortedMap = -1
)
ItemSortedMap is a nonce->item map with a heap based index to allow iterating over the contents in a nonce-incrementing way.
Variables ¶
var ( ErrKnownTx = errors.New("Known Transaction") ErrUnknownTx = errors.New("Unknown Transaction") ErrDuplicatedNonceTx = errors.New("Duplicated Nonce Transaction") )
var DefaultBridgeTxPoolConfig = BridgeTxPoolConfig{ ParentChainID: big.NewInt(2018), Journal: "bridge_transactions.rlp", Rejournal: 10 * time.Minute, GlobalQueue: 8192, }
DefaultBridgeTxPoolConfig contains the default configurations for the transaction pool.
var (
ErrSizeLimit = errors.New("sorted map size limit")
)
Functions ¶
This section is empty.
Types ¶
type BridgeTxPool ¶
type BridgeTxPool struct {
// contains filtered or unexported fields
}
BridgeTxPool contains all currently known chain transactions.
func NewBridgeTxPool ¶
func NewBridgeTxPool(config BridgeTxPoolConfig) *BridgeTxPool
NewBridgeTxPool creates a new transaction pool to gather, sort and filter inbound transactions from the network.
func (*BridgeTxPool) AddLocal ¶
func (pool *BridgeTxPool) AddLocal(tx *types.Transaction) error
AddLocal enqueues a single transaction into the pool if it is valid, marking the sender as a local one.
func (*BridgeTxPool) AddLocals ¶
func (pool *BridgeTxPool) AddLocals(txs []*types.Transaction) []error
AddLocals enqueues a batch of transactions into the pool if they are valid, marking the senders as a local ones.
func (*BridgeTxPool) Content ¶
func (pool *BridgeTxPool) Content() map[common.Address]types.Transactions
Content retrieves the data content of the transaction pool, returning all the queued transactions, grouped by account and sorted by nonce.
func (*BridgeTxPool) Get ¶
func (pool *BridgeTxPool) Get(hash common.Hash) *types.Transaction
Get returns a transaction if it is contained in the pool and nil otherwise.
func (*BridgeTxPool) GetMaxTxNonce ¶
func (pool *BridgeTxPool) GetMaxTxNonce(from *common.Address) uint64
GetMaxTxNonce finds max nonce of the address.
func (*BridgeTxPool) GetTx ¶
func (pool *BridgeTxPool) GetTx(txHash common.Hash) (*types.Transaction, error)
GetTx get the tx by tx hash.
func (*BridgeTxPool) Pending ¶
func (pool *BridgeTxPool) Pending() map[common.Address]types.Transactions
Pending returns all pending transactions by calling internal pending method.
func (*BridgeTxPool) PendingTxHashesByAddress ¶
PendingTxHashesByAddress retrieves pending transaction hashes of from. They are sorted by nonce.
func (*BridgeTxPool) PendingTxsByAddress ¶
func (pool *BridgeTxPool) PendingTxsByAddress(from *common.Address, limit int) types.Transactions
PendingTxsByAddress retrieves pending transactions of from. They are sorted by nonce.
func (*BridgeTxPool) Remove ¶
func (pool *BridgeTxPool) Remove(txs types.Transactions) []error
Remove removes transactions from the queue.
func (*BridgeTxPool) RemoveTx ¶
func (pool *BridgeTxPool) RemoveTx(tx *types.Transaction) error
RemoveTx removes a single transaction from the queue.
func (*BridgeTxPool) SetEIP155Signer ¶
func (pool *BridgeTxPool) SetEIP155Signer(chainID *big.Int)
SetEIP155Signer set signer of txpool.
func (*BridgeTxPool) Stats ¶
func (pool *BridgeTxPool) Stats() int
Stats retrieves the current pool stats, namely the number of pending transactions.
type BridgeTxPoolConfig ¶
type BridgeTxPoolConfig struct { ParentChainID *big.Int Journal string // Journal of local transactions to survive node restarts Rejournal time.Duration // Time interval to regenerate the local transaction journal GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts }
BridgeTxPoolConfig are the configuration parameters of the transaction pool.
type DevNull ¶
type DevNull struct{}
DevNull is a WriteCloser that just discards anything written into it. Its goal is to allow the transaction journal to write into a fake journal when loading transactions on startup without printing warnings due to no file being readt for write.
type ItemSortedMap ¶
type ItemSortedMap struct {
// contains filtered or unexported fields
}
func NewItemSortedMap ¶
func NewItemSortedMap(size int) *ItemSortedMap
NewItemSortedMap creates a new nonce-sorted item map.
func (*ItemSortedMap) Exist ¶ added in v1.2.0
func (m *ItemSortedMap) Exist(nonce uint64) bool
Exist returns if the nonce exist.
func (*ItemSortedMap) Filter ¶
func (m *ItemSortedMap) Filter(filter func(interface{}) bool) items
Filter iterates over the list of items and removes all of them for which the specified function evaluates to true.
func (*ItemSortedMap) Flatten ¶
func (m *ItemSortedMap) Flatten() items
Flatten returns a nonce-sorted slice of items based on the loosely sorted internal representation. The result of the sorting is cached in case it's requested again before any modifications are made to the contents.
func (*ItemSortedMap) FlattenByCount ¶
func (m *ItemSortedMap) FlattenByCount(count int) items
FlattenByCount returns requested number of nonce-sorted slice of cached items. The result of the sorting is cached like as Flatten method.
func (*ItemSortedMap) Forward ¶ added in v1.3.0
func (m *ItemSortedMap) Forward(threshold uint64) items
Forward removes all items from the map with a nonce lower than the provided threshold. Every removed transaction is returned for any post-removal maintenance.
func (*ItemSortedMap) Get ¶
func (m *ItemSortedMap) Get(nonce uint64) itemWithNonce
Get retrieves the current items associated with the given nonce.
func (*ItemSortedMap) Pop ¶ added in v1.2.0
func (m *ItemSortedMap) Pop(count int) items
Pop removes given count number of minimum nonce items from the map. Every removed items is returned for any post-removal maintenance.
func (*ItemSortedMap) Put ¶
func (m *ItemSortedMap) Put(event itemWithNonce) error
Put inserts a new item into the map, also updating the map's nonce index. If a item already exists with the same nonce, it's overwritten.
func (*ItemSortedMap) Ready ¶
func (m *ItemSortedMap) Ready(start uint64) items
Ready retrieves a sequentially increasing list of events starting at the provided nonce that is ready for processing. The returned events will be removed from the list.
Note, all events with nonces lower than start will also be returned to prevent getting into and invalid state. This is not something that should ever happen but better to be self correcting than failing!
func (*ItemSortedMap) Remove ¶
func (m *ItemSortedMap) Remove(nonce uint64) bool
Remove deletes a item from the maintained map, returning whether the item was found.