Documentation ¶
Index ¶
- Constants
- func BigHexToBigDecimal(num *hexutil.Big) *big.Int
- func BigHexToBigFloat(num *hexutil.Big) (*big.Float, error)
- func BigIntToBigFloat(num *big.Int) (*big.Float, error)
- func CleanSlice(txs []*MemPoolTx)
- func HexToDecimal(num hexutil.Uint64) string
- func HumanReadableGasPrice(num *hexutil.Big) string
- func IsPresentInCurrentPool(txs map[string]map[string]*MemPoolTx, txHash common.Hash) bool
- func TrackNotFoundTxs(ctx context.Context, inPendingPoolChan <-chan *MemPoolTx, ...)
- type AddRequest
- type ConfirmedTx
- type CountRequest
- type ExistsRequest
- type GetRequest
- type LastSeenBlock
- type ListRequest
- type MemPool
- func (m *MemPool) DoneTxCount() uint64
- func (m *MemPool) Exists(hash common.Hash) bool
- func (m *MemPool) Get(hash common.Hash) *MemPoolTx
- func (m *MemPool) HandleTxFromPeer(ctx context.Context, pubsub *redis.Client, tx *MemPoolTx) bool
- func (m *MemPool) LastSeenBlock() LastSeenBlock
- func (m *MemPool) PendingDuplicates(hash common.Hash) []*MemPoolTx
- func (m *MemPool) PendingForGTE(x time.Duration) []*MemPoolTx
- func (m *MemPool) PendingForLTE(x time.Duration) []*MemPoolTx
- func (m *MemPool) PendingFrom(address common.Address) []*MemPoolTx
- func (m *MemPool) PendingPoolLength() uint64
- func (m *MemPool) PendingTo(address common.Address) []*MemPoolTx
- func (m *MemPool) Process(ctx context.Context, pending map[string]map[string]*MemPoolTx, ...)
- func (m *MemPool) QueuedDuplicates(hash common.Hash) []*MemPoolTx
- func (m *MemPool) QueuedForGTE(x time.Duration) []*MemPoolTx
- func (m *MemPool) QueuedForLTE(x time.Duration) []*MemPoolTx
- func (m *MemPool) QueuedFrom(address common.Address) []*MemPoolTx
- func (m *MemPool) QueuedPoolLength() uint64
- func (m *MemPool) QueuedTo(address common.Address) []*MemPoolTx
- func (m *MemPool) Stat(start time.Time)
- func (m *MemPool) TopXPendingWithHighGasPrice(x uint64) []*MemPoolTx
- func (m *MemPool) TopXPendingWithLowGasPrice(x uint64) []*MemPoolTx
- func (m *MemPool) TopXQueuedWithHighGasPrice(x uint64) []*MemPoolTx
- func (m *MemPool) TopXQueuedWithLowGasPrice(x uint64) []*MemPoolTx
- type MemPoolTx
- func (m *MemPoolTx) IsDropped(ctx context.Context, rpc *rpc.Client) (bool, error)
- func (m *MemPoolTx) IsDuplicateOf(tx *MemPoolTx) bool
- func (m *MemPoolTx) IsLowerNonce(tx *MemPoolTx) bool
- func (m *MemPoolTx) IsNonceExhausted(ctx context.Context, rpc *rpc.Client) (bool, error)
- func (m *MemPoolTx) IsPendingForGTE(x time.Duration) bool
- func (m *MemPoolTx) IsPendingForLTE(x time.Duration) bool
- func (m *MemPoolTx) IsQueuedForGTE(x time.Duration) bool
- func (m *MemPoolTx) IsQueuedForLTE(x time.Duration) bool
- func (m *MemPoolTx) IsSentFrom(address common.Address) bool
- func (m *MemPoolTx) IsSentTo(address common.Address) bool
- func (m *MemPoolTx) IsUnstuck(ctx context.Context, rpc *rpc.Client) (bool, error)
- func (m *MemPoolTx) ToGraphQL() *model.MemPoolTx
- func (m *MemPoolTx) ToMessagePack() ([]byte, error)
- type MemPoolTxsAsc
- type MemPoolTxsDesc
- type Msg
- type NewSeenBlock
- type PendingPool
- func (p *PendingPool) Add(ctx context.Context, tx *MemPoolTx) bool
- func (p *PendingPool) AddPendings(ctx context.Context, txs map[string]map[string]*MemPoolTx) uint64
- func (p *PendingPool) AddUnstuck(ctx context.Context, tx *MemPoolTx) bool
- func (p *PendingPool) AscListTxs() []*MemPoolTx
- func (p *PendingPool) Count() uint64
- func (p *PendingPool) DescListTxs() []*MemPoolTx
- func (p *PendingPool) DuplicateTxs(hash common.Hash) []*MemPoolTx
- func (p *PendingPool) Exists(hash common.Hash) bool
- func (p *PendingPool) FresherThanX(x time.Duration) []*MemPoolTx
- func (p *PendingPool) Get(hash common.Hash) *MemPoolTx
- func (p *PendingPool) GetLastSeenBlock() LastSeenBlock
- func (p *PendingPool) OlderThanX(x time.Duration) []*MemPoolTx
- func (p *PendingPool) Processed() uint64
- func (p *PendingPool) Prunables(targetTx *MemPoolTx) []*MemPoolTx
- func (p *PendingPool) Prune(ctx context.Context, caughtTxsChan <-chan listen.CaughtTxs, ...)
- func (p *PendingPool) PublishAdded(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
- func (p *PendingPool) PublishRemoved(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
- func (p *PendingPool) Remove(ctx context.Context, txStat *TxStatus) bool
- func (p *PendingPool) SentFrom(address common.Address) []*MemPoolTx
- func (p *PendingPool) SentTo(address common.Address) []*MemPoolTx
- func (p *PendingPool) Start(ctx context.Context)
- func (p *PendingPool) TopXWithHighGasPrice(x uint64) []*MemPoolTx
- func (p *PendingPool) TopXWithLowGasPrice(x uint64) []*MemPoolTx
- func (p *PendingPool) TxsFromA(addr common.Address) []*MemPoolTx
- func (p *PendingPool) VerifiedAdd(ctx context.Context, tx *MemPoolTx) bool
- type QueuedPool
- func (q *QueuedPool) Add(ctx context.Context, tx *MemPoolTx) bool
- func (q *QueuedPool) AddQueued(ctx context.Context, txs map[string]map[string]*MemPoolTx) uint64
- func (q *QueuedPool) AscListTxs() []*MemPoolTx
- func (q *QueuedPool) Count() uint64
- func (q *QueuedPool) DescListTxs() []*MemPoolTx
- func (q *QueuedPool) DuplicateTxs(hash common.Hash) []*MemPoolTx
- func (q *QueuedPool) Exists(hash common.Hash) bool
- func (q *QueuedPool) FresherThanX(x time.Duration) []*MemPoolTx
- func (q *QueuedPool) Get(hash common.Hash) *MemPoolTx
- func (q *QueuedPool) OlderThanX(x time.Duration) []*MemPoolTx
- func (q *QueuedPool) Prune(ctx context.Context, confirmedTxsChan chan ConfirmedTx, ...)
- func (q *QueuedPool) PublishAdded(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
- func (q *QueuedPool) PublishRemoved(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
- func (q *QueuedPool) Remove(ctx context.Context, txHash common.Hash) *MemPoolTx
- func (q *QueuedPool) SentFrom(address common.Address) []*MemPoolTx
- func (q *QueuedPool) SentTo(address common.Address) []*MemPoolTx
- func (q *QueuedPool) Start(ctx context.Context)
- func (q *QueuedPool) TopXWithHighGasPrice(x uint64) []*MemPoolTx
- func (q *QueuedPool) TopXWithLowGasPrice(x uint64) []*MemPoolTx
- func (q *QueuedPool) TxsFromA(addr common.Address) []*MemPoolTx
- type RemoveRequest
- type RemoveTxsFromPendingPool
- type RemoveTxsFromQueuedPool
- type RemovedUnstuckTx
- type Resource
- type Stat
- type TxList
- type TxStatus
- type TxsFromARequest
- type TxsFromAddressAsc
Constants ¶
const ( ASC = iota DESC )
Sorting direction representation
const ( EMPTY = iota PRUNING SCHEDULED )
When submitting async request for pruning pending/ queued pool, immediate response to be sent to client in any of these form(s)
const ( STUCK = iota + 1 UNSTUCK PENDING CONFIRMED DROPPED )
Variables ¶
This section is empty.
Functions ¶
func BigHexToBigDecimal ¶
BigHexToBigDecimal - Given a hex encoded big number, converts it to decimal big integer
func BigHexToBigFloat ¶
BigHexToBigFloat - Converts hex encoded big integer to big floating point number
@note To be used for better precision flaoting point arithmetic
func BigIntToBigFloat ¶
BigIntToBigFloat - Given big number, attempts to convert it to big floating point number
func CleanSlice ¶ added in v0.8.0
func CleanSlice(txs []*MemPoolTx)
CleanSlice - When we're done using one slice of txs, it's better to clean those up, so that it becomes eligible for GC
func HexToDecimal ¶
HexToDecimal - Converts hex encoded uint64 to decimal string
func HumanReadableGasPrice ¶
HumanReadableGasPrice - Returns gas price paid for tx in Gwei unit
func IsPresentInCurrentPool ¶
IsPresentInCurrentPool - Given tx hash, which was previously present in pending/ queued pool attempts to check whether it's present in current txpool content or not
@note `txs` is current pending/ queued pool state received over RPC interface
func TrackNotFoundTxs ¶ added in v0.9.0
func TrackNotFoundTxs(ctx context.Context, inPendingPoolChan <-chan *MemPoolTx, notFoundTxsChan <-chan listen.CaughtTxs, alreadyMinedTxChan chan<- listen.CaughtTxs)
TrackNotFoundTxs - Those tx(s) which are found to be mined before actual pending tx is added into mempool, are kept track of here & pending pool pruner is informed about it, when it's found to be joining mempool, in some time future.
Types ¶
type AddRequest ¶ added in v0.7.0
AddRequest - For adding new tx into pool
type ConfirmedTx ¶ added in v0.8.0
ConfirmedTx - When we learn a certain tx has been confirmed by listening to blocks getting mined, we'll attempt to dequeue any stuck tx from queued pool & put it into pending pool
type CountRequest ¶ added in v0.7.0
type CountRequest struct {
ResponseChan chan uint64
}
CountRequest - Getting #-of txs present in pool
type ExistsRequest ¶ added in v0.7.0
ExistsRequest - Checking whether tx is present in pool or not
type GetRequest ¶ added in v0.7.0
GetRequest - Obtaining reference to existing tx in pool
type LastSeenBlock ¶ added in v0.8.1
LastSeenBlock - Which block number was last seen by header subscriber along with time
type ListRequest ¶ added in v0.7.0
ListRequest - Listing all txs in pool
type MemPool ¶
type MemPool struct { Pending *PendingPool Queued *QueuedPool }
MemPool - Current state of mempool, where all pending/ queued tx(s) are present. Among these pending tx(s), any of them can be picked up during next block mining phase, but any tx(s) present in queued pool, can't be picked up until some problem with sender address is resolved.
Tx(s) ending up in queued pool, happens very commonly due to account nonce gaps
func (*MemPool) DoneTxCount ¶ added in v0.8.1
DoneTxCount - #-of tx(s) seen to processed during this node's life time
func (*MemPool) Exists ¶ added in v0.4.0
Exists - Given a txHash, attempts to check whether this tx is present in either of pending/ queued pool
func (*MemPool) Get ¶ added in v0.4.0
Get - Given a txhash, attempts to find out tx, if present in any of pending/ queued pool
func (*MemPool) HandleTxFromPeer ¶ added in v0.5.0
HandleTxFromPeer - When new chunk of deserialised in-flight tx ( i.e. entering/ leaving mempool ) is received from any `harmony` peer, it will be checked against latest state of local mempool view, to decide whether this tx can be acted upon somehow or not
func (*MemPool) LastSeenBlock ¶ added in v0.8.1
func (m *MemPool) LastSeenBlock() LastSeenBlock
LastSeenBlock - Last seen block by mempool & when it was seen, to be invoked by stat generator http request handler method
func (*MemPool) PendingDuplicates ¶ added in v0.3.0
PendingDuplicates - Find duplicate tx(s), given txHash, present in pending mempool
func (*MemPool) PendingForGTE ¶
PendingForGTE - Returning list of tx(s), pending for more than x time unit
func (*MemPool) PendingForLTE ¶
PendingForLTE - Returning list of tx(s), pending for less than x time unit
func (*MemPool) PendingFrom ¶
PendingFrom - List of tx(s) pending from address
@note These are going to be same nonce tx(s), only one of them will make to next block, others to be dropped
func (*MemPool) PendingPoolLength ¶
PendingPoolLength - Returning current pending tx queue length
func (*MemPool) PendingTo ¶
PendingTo - List of tx(s) living in pending pool, sent to specified address
func (*MemPool) Process ¶
func (m *MemPool) Process(ctx context.Context, pending map[string]map[string]*MemPoolTx, queued map[string]map[string]*MemPoolTx)
Process - Process all current pending & queued tx pool content & populate our in-memory buffer
func (*MemPool) QueuedDuplicates ¶ added in v0.3.0
QueuedDuplicates - Find duplicate tx(s), given txHash, present in queued mempool
func (*MemPool) QueuedForGTE ¶
QueuedForGTE - Returning list of tx(s), queued for more than x time unit
func (*MemPool) QueuedForLTE ¶
QueuedForLTE - Returning list of tx(s), queued for less than x time unit
func (*MemPool) QueuedFrom ¶
QueuedFrom - List of stuck tx(s) from specified address, due to nonce gap
func (*MemPool) QueuedPoolLength ¶
QueuedPoolLength - Returning current queued tx queue length
func (*MemPool) QueuedTo ¶
QueuedTo - List of stuck tx(s) present in queued pool, sent to specified address
func (*MemPool) TopXPendingWithHighGasPrice ¶
TopXPendingWithHighGasPrice - Returns a list of top `X` pending tx(s) where high gas price tx(s) are prioritized
func (*MemPool) TopXPendingWithLowGasPrice ¶
TopXPendingWithLowGasPrice - Returns a list of top `X` pending tx(s) where low gas price tx(s) are prioritized
func (*MemPool) TopXQueuedWithHighGasPrice ¶
TopXQueuedWithHighGasPrice - Returns a list of top `X` queued tx(s) where high gas price tx(s) are prioritized
func (*MemPool) TopXQueuedWithLowGasPrice ¶
TopXQueuedWithLowGasPrice - Returns a list of top `X` queued tx(s) where low gas price tx(s) are prioritized
type MemPoolTx ¶
type MemPoolTx struct { BlockHash *common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *common.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` Value *hexutil.Big `json:"value"` Type hexutil.Uint64 `json:"type"` ChainID *hexutil.Big `json:"chainId,omitempty"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` QueuedAt time.Time UnstuckAt time.Time PendingFrom time.Time ConfirmedAt time.Time DroppedAt time.Time Pool string ReceivedFrom string }
MemPoolTx - This is how tx is placed in mempool, after performing RPC call for fetching currently pending/ queued tx(s) in mempool it'll be destructured into this format, for further computation
func FromMessagePack ¶
FromMessagePack - Given serialized byte array, attempts to deserialize into structured tx format
func UntilNonceGap ¶ added in v0.8.0
UntilNonceGap - Returns subslice of txs, where no nonce-gap exists for `> nonce + 1`
func (*MemPoolTx) IsDropped ¶ added in v0.4.0
IsDropped - Attempts to check whether this tx was dropped by node or not
Dropping can happen due to higher priority tx from same account with same nonce was encountered
func (*MemPoolTx) IsDuplicateOf ¶ added in v0.4.0
IsDuplicateOf - Checks whether one tx is duplicate of another one or not
@note Two tx(s) are considered to be duplicate of each other when both of them having same from address & nonce
func (*MemPoolTx) IsLowerNonce ¶ added in v0.7.0
IsLowerNonce - Objective is to find out whether `m` has same of lower nonce than `tx`
func (*MemPoolTx) IsNonceExhausted ¶
IsNonceExhausted - Multiple tx(s) of same/ different value can be sent to network with same nonce, where one of them which seems most profitable to miner, will be picked up, while mining next block
This function will help us in checking whether nonce of this tx is exhausted or not i.e. whether some other tx is same nonce is mined or not
If mined, we can drop this tx from mempool
func (*MemPoolTx) IsPendingForGTE ¶
IsPendingForGTE - Test if this tx has been in pending pool for more than or equal to `X` time unit
func (*MemPoolTx) IsPendingForLTE ¶
IsPendingForLTE - Test if this tx has been in pending pool for less than or equal to `X` time unit
func (*MemPoolTx) IsQueuedForGTE ¶
IsQueuedForGTE - Test if this tx has been in queued pool for more than or equal to `X` time unit
func (*MemPoolTx) IsQueuedForLTE ¶
IsQueuedForLTE - Test if this tx has been in queued pool for less than or equal to `X` time unit
func (*MemPoolTx) IsSentFrom ¶
IsSentFrom - Checks whether this tx was sent from specified address or not
func (*MemPoolTx) IsSentTo ¶
IsSentTo - Checks if this was sent to certain address ( EOA/ Contract )
@note If it's a contract creation tx, it'll not have `to` address
func (*MemPoolTx) IsUnstuck ¶
IsUnstuck - Checking whether this tx is unstuck now
@note Tx(s) generally get stuck in queued pool due to nonce gaps
func (*MemPoolTx) ToMessagePack ¶
ToMessagePack - Serialize to message pack encoded byte array format
type MemPoolTxsAsc ¶
type MemPoolTxsAsc []*MemPoolTx
MemPoolTxsAsc - List of mempool tx(s)
@note This structure to be used for sorting tx(s) in ascending way, using gas price they're paying
type MemPoolTxsDesc ¶
type MemPoolTxsDesc []*MemPoolTx
MemPoolTxsDesc - List of mempool tx(s)
@note This structure to be used for sorting tx(s) in descending way, using gas price they're paying
type NewSeenBlock ¶ added in v0.8.1
NewSeenBlock - When new block is seen by header listener, concurrent-safe updation is sent to pending pool worker
type PendingPool ¶
type PendingPool struct { Transactions map[common.Hash]*MemPoolTx TxsFromAddress map[common.Address]TxList DroppedTxs map[common.Hash]bool RemovedTxs map[common.Hash]bool AscTxsByGasPrice TxList DescTxsByGasPrice TxList Done uint64 LastSeenBlock uint64 LastSeenAt time.Time AddTxChan chan AddRequest AddFromQueuedPoolChan chan AddRequest RemoveTxChan chan RemoveRequest AlreadyInPendingPoolChan chan *MemPoolTx InPendingPoolChan chan<- *MemPoolTx TxExistsChan chan ExistsRequest GetTxChan chan GetRequest CountTxsChan chan CountRequest ListTxsChan chan ListRequest TxsFromAChan chan TxsFromARequest DoneChan chan chan uint64 SetLastSeenBlockChan chan uint64 LastSeenBlockChan chan chan LastSeenBlock PubSub *redis.Client RPC *rpc.Client }
PendingPool - Currently present pending tx(s) i.e. which are ready to be mined in next block
func (*PendingPool) Add ¶
func (p *PendingPool) Add(ctx context.Context, tx *MemPoolTx) bool
Add - Attempts to add new tx found in pending pool into harmony mempool, so that further manipulation can be performed on it
If it returns `true`, it denotes, it's success, otherwise it's failure because this tx is already present in pending pool
func (*PendingPool) AddPendings ¶
AddPendings - Update latest pending pool state
func (*PendingPool) AddUnstuck ¶ added in v0.8.0
func (p *PendingPool) AddUnstuck(ctx context.Context, tx *MemPoolTx) bool
AddUnstuck - When attempting to add new tx from queued pool to here it's supposed to be invoked so that queued pool doesn't receive notification back to self for so
func (*PendingPool) AscListTxs ¶ added in v0.7.0
func (p *PendingPool) AscListTxs() []*MemPoolTx
AscListTxs - Returns all tx(s) present in pending pool, as slice, ascending ordered as per gas price paid
func (*PendingPool) Count ¶
func (p *PendingPool) Count() uint64
Count - How many tx(s) currently present in pending pool
func (*PendingPool) DescListTxs ¶ added in v0.7.0
func (p *PendingPool) DescListTxs() []*MemPoolTx
DescListTxs - Returns all tx(s) present in pending pool, as slice, descending ordered as per gas price paid
func (*PendingPool) DuplicateTxs ¶ added in v0.3.0
func (p *PendingPool) DuplicateTxs(hash common.Hash) []*MemPoolTx
DuplicateTxs - Attempting to find duplicate tx(s) for given txHash.
@note In duplicate tx list, the tx which was provided as input will not be included
Considering one tx duplicate of given one, if this tx has same nonce & sender address, as of given ones
func (*PendingPool) Exists ¶ added in v0.4.0
func (p *PendingPool) Exists(hash common.Hash) bool
Exists - Checks whether tx of given hash exists on pending pool or not
func (*PendingPool) FresherThanX ¶
func (p *PendingPool) FresherThanX(x time.Duration) []*MemPoolTx
FresherThanX - Returns a list of all pending tx(s), which are living in mempool for less than or equals to `X` time unit
func (*PendingPool) Get ¶ added in v0.4.0
func (p *PendingPool) Get(hash common.Hash) *MemPoolTx
Get - Given tx hash, attempts to find out tx in pending pool, if any
Returns nil, if found nothing
func (*PendingPool) GetLastSeenBlock ¶ added in v0.8.1
func (p *PendingPool) GetLastSeenBlock() LastSeenBlock
GetLastSeenBlock - Get last seen block & time, as reported by block header listener
func (*PendingPool) OlderThanX ¶
func (p *PendingPool) OlderThanX(x time.Duration) []*MemPoolTx
OlderThanX - Returns a list of all pending tx(s), which are living in mempool for more than or equals to `X` time unit
func (*PendingPool) Processed ¶ added in v0.8.1
func (p *PendingPool) Processed() uint64
Processed - These many tx(s) have permanently left mempool as seen by this `harmony` instance during its life time
This is nothing but count of `dropped` & `confirmed` tx(s)
func (*PendingPool) Prunables ¶ added in v0.7.0
func (p *PendingPool) Prunables(targetTx *MemPoolTx) []*MemPoolTx
Prunables - Given tx, we're attempting to find out all txs which are living in pending pool now & having same sender address & same/ lower nonce, so that pruner can update state while removing mined txs from mempool
func (*PendingPool) Prune ¶ added in v0.7.0
func (p *PendingPool) Prune(ctx context.Context, caughtTxsChan <-chan listen.CaughtTxs, confirmedTxsChan chan<- ConfirmedTx, notFoundTxsChan chan<- listen.CaughtTxs)
Prune - Remove confirmed/ dropped txs from pending pool
@note This method is supposed to be run as independent go routine
func (*PendingPool) PublishAdded ¶
func (p *PendingPool) PublishAdded(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
PublishAdded - Publish new pending tx pool content ( in messagepack serialized format ) to pubsub topic
func (*PendingPool) PublishRemoved ¶
func (p *PendingPool) PublishRemoved(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
PublishRemoved - Publish old pending tx pool content ( in messagepack serialized format ) to pubsub topic
These tx(s) are leaving pending pool i.e. they're confirmed now
func (*PendingPool) Remove ¶
func (p *PendingPool) Remove(ctx context.Context, txStat *TxStatus) bool
Remove - Removes already existing tx from pending tx pool denoting it has been mined i.e. confirmed/ dropped ( possible too )
func (*PendingPool) SentFrom ¶
func (p *PendingPool) SentFrom(address common.Address) []*MemPoolTx
SentFrom - Returns a list of pending tx(s) sent from specified address
func (*PendingPool) SentTo ¶
func (p *PendingPool) SentTo(address common.Address) []*MemPoolTx
SentTo - Returns a list of pending tx(s) sent to specified address
func (*PendingPool) Start ¶ added in v0.7.0
func (p *PendingPool) Start(ctx context.Context)
Start - This method is supposed to be run as an independent go routine, maintaining pending pool state, through out its life time
func (*PendingPool) TopXWithHighGasPrice ¶
func (p *PendingPool) TopXWithHighGasPrice(x uint64) []*MemPoolTx
TopXWithHighGasPrice - Returns only top `X` tx(s) present in pending mempool, where being top is determined by how much gas price paid by tx sender
func (*PendingPool) TopXWithLowGasPrice ¶
func (p *PendingPool) TopXWithLowGasPrice(x uint64) []*MemPoolTx
TopXWithLowGasPrice - Returns only top `X` tx(s) present in pending mempool, where being top is determined by how low gas price paid by tx sender
func (*PendingPool) TxsFromA ¶ added in v0.8.0
func (p *PendingPool) TxsFromA(addr common.Address) []*MemPoolTx
TxsFromA - Returns a slice of txs, where all of those are sent by address `A`
func (*PendingPool) VerifiedAdd ¶ added in v0.7.0
func (p *PendingPool) VerifiedAdd(ctx context.Context, tx *MemPoolTx) bool
VerifiedAdd - Before adding tx from queued pool, just check do we really need to add this tx in pending pool i.e. is this tx really pending ?
type QueuedPool ¶
type QueuedPool struct { Transactions map[common.Hash]*MemPoolTx TxsFromAddress map[common.Address]TxList DroppedTxs map[common.Hash]bool RemovedTxs map[common.Hash]bool AscTxsByGasPrice TxList DescTxsByGasPrice TxList AddTxChan chan AddRequest RemoveTxChan chan RemovedUnstuckTx TxExistsChan chan ExistsRequest GetTxChan chan GetRequest CountTxsChan chan CountRequest ListTxsChan chan ListRequest TxsFromAChan chan TxsFromARequest PubSub *redis.Client RPC *rpc.Client PendingPool *PendingPool }
QueuedPool - Currently present queued tx(s) i.e. these tx(s) are stuck due to some reasons, one very common reason is nonce gap
What it essentially denotes is, these tx(s) are not ready to be picked up when next block is going to be picked, when these tx(s) are going to be moved to pending pool, only they can be considered before mining
func (*QueuedPool) Add ¶
func (q *QueuedPool) Add(ctx context.Context, tx *MemPoolTx) bool
Add - Attempts to add new tx found in pending pool into harmony mempool, so that further manipulation can be performed on it
If it returns `true`, it denotes, it's success, otherwise it's failure because this tx is already present in pending pool
func (*QueuedPool) AscListTxs ¶ added in v0.7.0
func (q *QueuedPool) AscListTxs() []*MemPoolTx
AscListTxs - Returns all tx(s) present in queued pool, as slice, ascending ordered as per gas price paid
func (*QueuedPool) Count ¶
func (q *QueuedPool) Count() uint64
Count - How many tx(s) currently present in pending pool
func (*QueuedPool) DescListTxs ¶ added in v0.7.0
func (q *QueuedPool) DescListTxs() []*MemPoolTx
DescListTxs - Returns all tx(s) present in queued pool, as slice, descending ordered as per gas price paid
func (*QueuedPool) DuplicateTxs ¶ added in v0.3.0
func (q *QueuedPool) DuplicateTxs(hash common.Hash) []*MemPoolTx
DuplicateTxs - Attempting to find duplicate tx(s) for given txHash.
@note In duplicate tx list, the tx which was provided as input will not be included
Considering one tx duplicate of given one, if this tx has same nonce & sender address, as of given ones
func (*QueuedPool) Exists ¶ added in v0.4.0
func (q *QueuedPool) Exists(hash common.Hash) bool
Exists - Checks whether tx of given hash exists on queued pool or not
func (*QueuedPool) FresherThanX ¶
func (q *QueuedPool) FresherThanX(x time.Duration) []*MemPoolTx
FresherThanX - Returns a list of all queued tx(s), which are living in mempool for less than or equals to `X` time unit
func (*QueuedPool) Get ¶ added in v0.4.0
func (q *QueuedPool) Get(hash common.Hash) *MemPoolTx
Get - Given tx hash, attempts to find out tx in queued pool, if any
Returns nil, if found nothing
func (*QueuedPool) OlderThanX ¶
func (q *QueuedPool) OlderThanX(x time.Duration) []*MemPoolTx
OlderThanX - Returns a list of all queued tx(s), which are living in mempool for more than or equals to `X` time unit
func (*QueuedPool) Prune ¶ added in v0.7.0
func (q *QueuedPool) Prune(ctx context.Context, confirmedTxsChan chan ConfirmedTx, pendingTxsChan chan *MemPoolTx)
Prune - Remove unstuck txs from queued pool & also attempt to place them in pending pool, if not present already
@note Start this method as an independent go routine
func (*QueuedPool) PublishAdded ¶
func (q *QueuedPool) PublishAdded(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
PublishAdded - Publish new tx, entered queued pool, ( in messagepack serialized format ) to pubsub topic
func (*QueuedPool) PublishRemoved ¶
func (q *QueuedPool) PublishRemoved(ctx context.Context, pubsub *redis.Client, msg *MemPoolTx)
PublishRemoved - Publish unstuck tx, leaving queued pool ( in messagepack serialized format ) to pubsub topic
These tx(s) are leaving queued pool i.e. they're ( probably ) going to sit in pending pool now, unless they're already mined & harmony failed to keep track of it
func (*QueuedPool) SentFrom ¶
func (q *QueuedPool) SentFrom(address common.Address) []*MemPoolTx
SentFrom - Returns a list of queued tx(s) sent from specified address
func (*QueuedPool) SentTo ¶
func (q *QueuedPool) SentTo(address common.Address) []*MemPoolTx
SentTo - Returns a list of queued tx(s) sent to specified address
func (*QueuedPool) Start ¶ added in v0.7.0
func (q *QueuedPool) Start(ctx context.Context)
Start - This method is supposed to be started as a seperate go routine which will manage queued pool ops through out its life
func (*QueuedPool) TopXWithHighGasPrice ¶
func (q *QueuedPool) TopXWithHighGasPrice(x uint64) []*MemPoolTx
TopXWithHighGasPrice - Returns only top `X` tx(s) present in queued mempool, where being top is determined by how much gas price paid by tx sender
func (*QueuedPool) TopXWithLowGasPrice ¶
func (q *QueuedPool) TopXWithLowGasPrice(x uint64) []*MemPoolTx
TopXWithLowGasPrice - Returns only top `X` tx(s) present in queued mempool, where being top is determined by how low gas price paid by tx sender
type RemoveRequest ¶ added in v0.7.0
RemoveRequest - For removing existing tx into pool
type RemoveTxsFromPendingPool ¶ added in v0.7.0
RemoveTxsRequest - For checking which txs can be removed from pending pool, this request to be sent to pending pool manager
type RemoveTxsFromQueuedPool ¶ added in v0.7.0
type RemoveTxsFromQueuedPool struct { Pending map[string]map[string]*MemPoolTx Queued map[string]map[string]*MemPoolTx ResponseChan chan int }
RemoveTxsFromQueuedPool - For updating local queued pool state, request of this form to be sent to pool manager over channel, where it'll check which txs are likely to be unstuck & has moved to pending pool
type RemovedUnstuckTx ¶ added in v0.7.0
RemovedUnstuckTx - Remove unstuck tx from queued pool, request to be sent in this form
type Resource ¶
type Resource struct { RPCClient *rpc.Client WSClient *ethclient.Client Pool *MemPool Redis *redis.Client StartedAt time.Time NetworkID uint64 }
Resource - Shared resources among multiple go routines
Needs to be released carefully when shutting down
type Stat ¶
type Stat struct { PendingPoolSize uint64 `json:"pendingPoolSize"` QueuedPoolSize uint64 `json:"queuedPoolSize"` Uptime string `json:"uptime"` Processed uint64 `json:"processed"` LatestBlock uint64 `json:"latestBlock"` SeenAgo string `json:"latestSeenAgo"` NetworkID uint64 `json:"networkID"` }
Stat - Response to client queries for current mempool state to be sent in this form
type TxList ¶ added in v0.6.0
type TxList interface {
// contains filtered or unexported methods
}
type TxStatus ¶
TxStatus - When ever multiple go routines need to concurrently fetch status of tx, given hash they will communicate back to caller using this data structure, where `status` denotes result of intended check, which was performed concurrently
@note Data to be sent in this form over communication channel
type TxsFromARequest ¶ added in v0.8.0
TxsFromARequest - When requesting for txs living in pool sent from some specific address, use this construct
type TxsFromAddressAsc ¶ added in v0.8.0
type TxsFromAddressAsc []*MemPoolTx
TxsFromAddressAsc - List of txs, sent from same address sorted by their nonce