mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-28 21:16:29 +00:00
2eb3f414d8
* Support for local accounts why: Accounts tagged local will be packed with priority over untagged accounts * Added functions for queuing txs and simultaneously setting account locality why: Might be a popular task, in particular for unconditionally adding txs to a local (aka prioritised account) via "xp.addLocal(tx,true)" caveat: Untested yet * fix typo * backup * No baseFee for pre-London tx in verifier why: The packer would wrongly discard valid legacy txs.
71 lines
2.1 KiB
Nim
71 lines
2.1 KiB
Nim
# Nimbus
|
|
# Copyright (c) 2018 Status Research & Development GmbH
|
|
# Licensed under either of
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
# http://opensource.org/licenses/MIT)
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
# according to those terms.
|
|
|
|
## Transaction Pool Tasklet: Recover From Waste Basket or Create
|
|
## =============================================================
|
|
##
|
|
|
|
import
|
|
../tx_desc,
|
|
../tx_info,
|
|
../tx_item,
|
|
../tx_tabs,
|
|
chronicles,
|
|
eth/[common, keys],
|
|
stew/keyed_queue
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
logScope:
|
|
topics = "tx-pool recover item"
|
|
|
|
let
|
|
nullSender = block:
|
|
var rc: EthAddress
|
|
rc
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Public functions
|
|
# ------------------------------------------------------------------------------
|
|
|
|
proc recoverItem*(xp: TxPoolRef; tx: Transaction;
|
|
status = txItemPending; info = ""): Result[TxItemRef,TxInfo]
|
|
{.gcsafe,raises: [Defect,CatchableError].} =
|
|
## Recover item from waste basket or create new. It is an error if the item
|
|
## is in the buckets database, already.
|
|
let itemID = tx.itemID
|
|
|
|
# Test whether the item is in the database, already
|
|
if xp.txDB.byItemID.hasKey(itemID):
|
|
return err(txInfoErrAlreadyKnown)
|
|
|
|
# Check whether the tx can be re-cycled from waste basket
|
|
block:
|
|
let rc = xp.txDB.byRejects.delete(itemID)
|
|
if rc.isOK:
|
|
let item = rc.value.data
|
|
# must not be a waste tx without meta-data
|
|
if item.sender != nullSender:
|
|
let itemInfo = if info != "": info else: item.info
|
|
item.init(status, itemInfo)
|
|
return ok(item)
|
|
|
|
# New item generated from scratch, e.g. with `nullSender`
|
|
block:
|
|
let rc = TxItemRef.new(tx, itemID, status, info)
|
|
if rc.isOk:
|
|
return ok(rc.value)
|
|
|
|
err(txInfoErrInvalidSender)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# End
|
|
# ------------------------------------------------------------------------------
|