data

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASC = iota
	DESC
)

Sorting direction representation

View Source
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)

View Source
const (
	STUCK = iota + 1
	UNSTUCK
	PENDING
	CONFIRMED
	DROPPED
)

Variables

This section is empty.

Functions

func BigHexToBigDecimal

func BigHexToBigDecimal(num *hexutil.Big) *big.Int

BigHexToBigDecimal - Given a hex encoded big number, converts it to decimal big integer

func BigHexToBigFloat

func BigHexToBigFloat(num *hexutil.Big) (*big.Float, error)

BigHexToBigFloat - Converts hex encoded big integer to big floating point number

@note To be used for better precision flaoting point arithmetic

func BigIntToBigFloat

func BigIntToBigFloat(num *big.Int) (*big.Float, error)

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

func HexToDecimal(num hexutil.Uint64) string

HexToDecimal - Converts hex encoded uint64 to decimal string

func HumanReadableGasPrice

func HumanReadableGasPrice(num *hexutil.Big) string

HumanReadableGasPrice - Returns gas price paid for tx in Gwei unit

func IsPresentInCurrentPool

func IsPresentInCurrentPool(txs map[string]map[string]*MemPoolTx, txHash common.Hash) bool

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 NumericGasPriceGwei added in v0.9.5

func NumericGasPriceGwei(num *hexutil.Big) float64

NumericGasPriceGwei - GasPrice in Gwei unit represented as floating point ( double precision )

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

type AddRequest struct {
	Tx           *MemPoolTx
	ResponseChan chan bool
}

AddRequest - For adding new tx into pool

type ConfirmedTx added in v0.8.0

type ConfirmedTx struct {
	From  common.Address
	Nonce hexutil.Uint64
}

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

type ExistsRequest struct {
	Tx           common.Hash
	ResponseChan chan bool
}

ExistsRequest - Checking whether tx is present in pool or not

type GetRequest added in v0.7.0

type GetRequest struct {
	Tx           common.Hash
	ResponseChan chan *MemPoolTx
}

GetRequest - Obtaining reference to existing tx in pool

type LastSeenBlock added in v0.8.1

type LastSeenBlock struct {
	Number uint64
	At     time.Time
}

LastSeenBlock - Which block number was last seen by header subscriber along with time

type ListRequest added in v0.7.0

type ListRequest struct {
	Order        int
	ResponseChan chan []*MemPoolTx
}

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

func (m *MemPool) DoneTxCount() uint64

DoneTxCount - #-of tx(s) seen to processed during this node's life time

func (*MemPool) Exists added in v0.4.0

func (m *MemPool) Exists(hash common.Hash) bool

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

func (m *MemPool) Get(hash common.Hash) *MemPoolTx

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

func (m *MemPool) HandleTxFromPeer(ctx context.Context, tx *MemPoolTx) bool

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

func (m *MemPool) PendingDuplicates(hash common.Hash) []*MemPoolTx

PendingDuplicates - Find duplicate tx(s), given txHash, present in pending mempool

func (*MemPool) PendingForGTE

func (m *MemPool) PendingForGTE(x time.Duration) []*MemPoolTx

PendingForGTE - Returning list of tx(s), pending for more than x time unit

func (*MemPool) PendingForLTE

func (m *MemPool) PendingForLTE(x time.Duration) []*MemPoolTx

PendingForLTE - Returning list of tx(s), pending for less than x time unit

func (*MemPool) PendingFrom

func (m *MemPool) PendingFrom(address common.Address) []*MemPoolTx

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

func (m *MemPool) PendingPoolLength() uint64

PendingPoolLength - Returning current pending tx queue length

func (*MemPool) PendingTo

func (m *MemPool) PendingTo(address common.Address) []*MemPoolTx

PendingTo - List of tx(s) living in pending pool, sent to specified address

func (*MemPool) PendingWithGTE added in v0.9.5

func (m *MemPool) PendingWithGTE(x float64) []*MemPoolTx

PendingWithGTE - Returns list of tx(s), pending with gas price >= `X`

func (*MemPool) PendingWithLTE added in v0.9.5

func (m *MemPool) PendingWithLTE(x float64) []*MemPoolTx

PendingWithLTE - Returns list of tx(s), pending with gas price <= `X`

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

func (m *MemPool) QueuedDuplicates(hash common.Hash) []*MemPoolTx

QueuedDuplicates - Find duplicate tx(s), given txHash, present in queued mempool

func (*MemPool) QueuedForGTE

func (m *MemPool) QueuedForGTE(x time.Duration) []*MemPoolTx

QueuedForGTE - Returning list of tx(s), queued for more than x time unit

func (*MemPool) QueuedForLTE

func (m *MemPool) QueuedForLTE(x time.Duration) []*MemPoolTx

QueuedForLTE - Returning list of tx(s), queued for less than x time unit

func (*MemPool) QueuedFrom

func (m *MemPool) QueuedFrom(address common.Address) []*MemPoolTx

QueuedFrom - List of stuck tx(s) from specified address, due to nonce gap

func (*MemPool) QueuedPoolLength

func (m *MemPool) QueuedPoolLength() uint64

QueuedPoolLength - Returning current queued tx queue length

func (*MemPool) QueuedTo

func (m *MemPool) QueuedTo(address common.Address) []*MemPoolTx

QueuedTo - List of stuck tx(s) present in queued pool, sent to specified address

func (*MemPool) QueuedWithGTE added in v0.9.5

func (m *MemPool) QueuedWithGTE(x float64) []*MemPoolTx

QueuedWithGTE - Returns list of tx(s), queued with gas price >= `X`

func (*MemPool) QueuedWithLTE added in v0.9.5

func (m *MemPool) QueuedWithLTE(x float64) []*MemPoolTx

QueuedWithLTE - Returns list of tx(s), queued with gas price <= `X`

func (*MemPool) Stat

func (m *MemPool) Stat(start time.Time)

Stat - Log current mempool state

func (*MemPool) TopXPendingWithHighGasPrice

func (m *MemPool) TopXPendingWithHighGasPrice(x uint64) []*MemPoolTx

TopXPendingWithHighGasPrice - Returns a list of top `X` pending tx(s) where high gas price tx(s) are prioritized

func (*MemPool) TopXPendingWithLowGasPrice

func (m *MemPool) TopXPendingWithLowGasPrice(x uint64) []*MemPoolTx

TopXPendingWithLowGasPrice - Returns a list of top `X` pending tx(s) where low gas price tx(s) are prioritized

func (*MemPool) TopXQueuedWithHighGasPrice

func (m *MemPool) TopXQueuedWithHighGasPrice(x uint64) []*MemPoolTx

TopXQueuedWithHighGasPrice - Returns a list of top `X` queued tx(s) where high gas price tx(s) are prioritized

func (*MemPool) TopXQueuedWithLowGasPrice

func (m *MemPool) TopXQueuedWithLowGasPrice(x uint64) []*MemPoolTx

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

func FromMessagePack(data []byte) (*MemPoolTx, error)

FromMessagePack - Given serialized byte array, attempts to deserialize into structured tx format

func UntilNonceGap added in v0.8.0

func UntilNonceGap(txs []*MemPoolTx, nonce hexutil.Uint64) []*MemPoolTx

UntilNonceGap - Returns subslice of txs, where no nonce-gap exists for `> nonce + 1`

func (*MemPoolTx) HasGasPriceLessThan added in v0.9.5

func (m *MemPoolTx) HasGasPriceLessThan(x float64) bool

HasGasPriceLessThan - Returns true if gas price of this tx is less than or equals to `X`

func (*MemPoolTx) HasGasPriceMoreThan added in v0.9.5

func (m *MemPoolTx) HasGasPriceMoreThan(x float64) bool

HasGasPriceMoreThan - Returns true if gas price of this tx is more than or equals to `X`

func (*MemPoolTx) IsDropped added in v0.4.0

func (m *MemPoolTx) IsDropped(ctx context.Context, rpc *rpc.Client) (bool, error)

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

func (m *MemPoolTx) IsDuplicateOf(tx *MemPoolTx) bool

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

func (m *MemPoolTx) IsLowerNonce(tx *MemPoolTx) bool

IsLowerNonce - Objective is to find out whether `m` has same of lower nonce than `tx`

func (*MemPoolTx) IsNonceExhausted

func (m *MemPoolTx) IsNonceExhausted(ctx context.Context, rpc *rpc.Client) (bool, error)

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

func (m *MemPoolTx) IsPendingForGTE(x time.Duration) bool

IsPendingForGTE - Test if this tx has been in pending pool for more than or equal to `X` time unit

func (*MemPoolTx) IsPendingForLTE

func (m *MemPoolTx) IsPendingForLTE(x time.Duration) bool

IsPendingForLTE - Test if this tx has been in pending pool for less than or equal to `X` time unit

func (*MemPoolTx) IsQueuedForGTE

func (m *MemPoolTx) IsQueuedForGTE(x time.Duration) bool

IsQueuedForGTE - Test if this tx has been in queued pool for more than or equal to `X` time unit

func (*MemPoolTx) IsQueuedForLTE

func (m *MemPoolTx) IsQueuedForLTE(x time.Duration) bool

IsQueuedForLTE - Test if this tx has been in queued pool for less than or equal to `X` time unit

func (*MemPoolTx) IsSentFrom

func (m *MemPoolTx) IsSentFrom(address common.Address) bool

IsSentFrom - Checks whether this tx was sent from specified address or not

func (*MemPoolTx) IsSentTo

func (m *MemPoolTx) IsSentTo(address common.Address) bool

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

func (m *MemPoolTx) IsUnstuck(ctx context.Context, rpc *rpc.Client) (bool, error)

IsUnstuck - Checking whether this tx is unstuck now

@note Tx(s) generally get stuck in queued pool due to nonce gaps

func (*MemPoolTx) ToGraphQL

func (m *MemPoolTx) ToGraphQL() *model.MemPoolTx

ToGraphQL - Convert to graphql compatible type

func (*MemPoolTx) ToMessagePack

func (m *MemPoolTx) ToMessagePack() ([]byte, error)

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 Msg

type Msg struct {
	Code    uint8  `json:"code,omitempty"`
	Message string `json:"message"`
}

Msg - Response message sent to client

type NewSeenBlock added in v0.8.1

type NewSeenBlock struct {
	Number       uint64
	ResponseChan chan bool
}

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]time.Time
	RemovedTxs               map[common.Hash]time.Time
	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                   *publisher.Publisher
	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

func (p *PendingPool) AddPendings(ctx context.Context, txs map[string]map[string]*MemPoolTx) uint64

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) HigherThanX added in v0.9.5

func (p *PendingPool) HigherThanX(x float64) []*MemPoolTx

HigherThanX - Returns a list of pending txs which are paid with gas price >= `X`

func (*PendingPool) LowerThanX added in v0.9.5

func (p *PendingPool) LowerThanX(x float64) []*MemPoolTx

LowerThanX - Returns a list of pending txs which are paid with gas price <= `X`

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, 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, 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]time.Time
	RemovedTxs        map[common.Hash]time.Time
	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            *publisher.Publisher
	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) AddQueued

func (q *QueuedPool) AddQueued(ctx context.Context, txs map[string]map[string]*MemPoolTx) uint64

AddQueued - Update latest queued pool state

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) HigherThanX added in v0.9.5

func (q *QueuedPool) HigherThanX(x float64) []*MemPoolTx

HigherThanX - Returns a list of queued txs which are paid with gas price >= `X`

func (*QueuedPool) LowerThanX added in v0.9.5

func (q *QueuedPool) LowerThanX(x float64) []*MemPoolTx

LowerThanX - Returns a list of queued txs which are paid with gas price <= `X`

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, 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, 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) Remove

func (q *QueuedPool) Remove(ctx context.Context, txHash common.Hash) *MemPoolTx

Remove - Removes unstuck tx from queued pool

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

func (*QueuedPool) TxsFromA added in v0.8.0

func (q *QueuedPool) TxsFromA(addr common.Address) []*MemPoolTx

TxsFromA - Returns a slice of txs, where all of those are sent by address `A`

type RemoveRequest added in v0.7.0

type RemoveRequest struct {
	TxStat       *TxStatus
	ResponseChan chan bool
}

RemoveRequest - For removing existing tx into pool

type RemoveTxsFromPendingPool added in v0.7.0

type RemoveTxsFromPendingPool struct {
	Txs          map[string]map[string]*MemPoolTx
	ResponseChan chan int
}

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

type RemovedUnstuckTx struct {
	Hash         common.Hash
	ResponseChan chan *MemPoolTx
}

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
	StartedAt time.Time
	NetworkID uint64
}

Resource - Shared resources among multiple go routines

Needs to be released carefully when shutting down

func (*Resource) Release

func (r *Resource) Release()

Release - To be called when application will receive shut down request from system, to gracefully deallocate all resources

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
}

func Insert added in v0.6.0

func Insert(txs TxList, tx *MemPoolTx) TxList

Insert - Insert tx into slice of sorted mempool txs, while keeping it sorted

If more memory allocation is required for inserting new element, it'll be done & new slice to be returned

func Remove added in v0.6.0

func Remove(txs TxList, tx *MemPoolTx) TxList

Remove - Removes existing entry from sorted slice of txs

type TxStatus

type TxStatus struct {
	Hash   common.Hash
	Status int
}

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

type TxsFromARequest struct {
	From         common.Address
	ResponseChan chan []*MemPoolTx
}

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

Jump to

Keyboard shortcuts

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