-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[submitter] track oldest pending txes age per chain #2819
Comments
To track the oldest pending transaction age per chain, follow these steps:
// chainQueue is a single use queue for a single chain.
type chainQueue struct {
// ... existing fields
oldestPendingTxAge time.Duration
}
func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID *big.Int, txes []db.TX) (err error) {
// ... existing code
// Calculate the oldest pending transaction age
if len(txes) > 0 {
oldestTx := txes[0]
for _, tx := range txes {
if tx.CreationTime().Before(oldestTx.CreationTime()) {
oldestTx = tx
}
}
cq.oldestPendingTxAge = time.Since(oldestTx.CreationTime())
}
// ... existing code
}
// txSubmitterImpl is the implementation of the transaction submitter.
type txSubmitterImpl struct {
// ... existing fields
oldestPendingTxAgePerChain *hashmap.Map[uint32, time.Duration]
}
func NewTransactionSubmitter(metrics metrics.Handler, signer signer.Signer, fetcher ClientFetcher, db db.Service, config config.IConfig) TransactionSubmitter {
return &txSubmitterImpl{
// ... existing fields
oldestPendingTxAgePerChain: hashmap.New[uint32, time.Duration](),
}
}
func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID *big.Int, txes []db.TX) (err error) {
// ... existing code
// Store the oldest pending transaction age
if len(txes) > 0 {
t.oldestPendingTxAgePerChain.Set(uint32(chainID.Int64()), cq.oldestPendingTxAge)
}
// ... existing code
} References/ethergo/submitter/chain_queue.go
|
Merged
Merged
trajan0x
added a commit
that referenced
this issue
Jun 29, 2024
address #2823, #2822, #2820 and #2819 --------- Co-authored-by: Trajan0x <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For each chain id track oldest pending nonce.
The text was updated successfully, but these errors were encountered: