Skip to content

Instantly share code, notes, and snippets.

@nakajo2011
Last active February 5, 2019 15:43
Show Gist options
  • Save nakajo2011/04c32d4fd6d71dbd985a602e673af09e to your computer and use it in GitHub Desktop.
Save nakajo2011/04c32d4fd6d71dbd985a602e673af09e to your computer and use it in GitHub Desktop.
20190206_blog_parts_rev_27ce4eb78bdf5d9b742ed05babe9b86a434733a1_tx_pool
if list := pool.pending[from]; list != nil && list.Overlaps(tx) {
// Nonce already pending, check if required price bump is met
inserted, old := list.Add(tx, pool.config.PriceBump)
if !inserted {
pendingDiscardCounter.Inc(1)
return false, ErrReplaceUnderpriced
}
// New transaction is better, replace old one
if old != nil {
pool.all.Remove(old.Hash())
pool.priced.Removed()
pendingReplaceCounter.Inc(1)
}
pool.all.Add(tx)
pool.priced.Put(tx)
pool.journalTx(from, tx)
log.Trace("Pooled new executable transaction", "hash", hash, "from", from, "to", tx.To())
// We've directly injected a replacement transaction, notify subsystems
go pool.txFeed.Send(NewTxsEvent{types.Transactions{tx}})
return old != nil, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment