mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-06 15:08:39 +00:00
core/txpool/blobpool: cheaper legacy tx detection in parseTransaction
This commit is contained in:
parent
3c8b108156
commit
66177b14ee
1 changed files with 11 additions and 7 deletions
|
|
@ -594,6 +594,9 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reser
|
||||||
// Migrate legacy transactions (types.Transaction) to pooledBlobTx format.
|
// Migrate legacy transactions (types.Transaction) to pooledBlobTx format.
|
||||||
if len(convertTxs) > 0 {
|
if len(convertTxs) > 0 {
|
||||||
for _, tx := range convertTxs {
|
for _, tx := range convertTxs {
|
||||||
|
if tx.BlobTxSidecar() == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
ptx := newBlobTxForPool(tx)
|
ptx := newBlobTxForPool(tx)
|
||||||
blob, err := rlp.EncodeToBytes(ptx)
|
blob, err := rlp.EncodeToBytes(ptx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -605,6 +608,8 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reser
|
||||||
}
|
}
|
||||||
meta := newBlobTxMeta(id, ptx.TxSize(), p.store.Size(id), ptx)
|
meta := newBlobTxMeta(id, ptx.TxSize(), p.store.Size(id), ptx)
|
||||||
|
|
||||||
|
// If the newly inserted transaction fails to be tracked,
|
||||||
|
// it should also be removed with those in `fails`
|
||||||
sender, err := types.Sender(p.signer, ptx.Tx)
|
sender, err := types.Sender(p.signer, ptx.Tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fails = append(fails, id)
|
fails = append(fails, id)
|
||||||
|
|
@ -708,14 +713,13 @@ func (p *BlobPool) Close() error {
|
||||||
func (p *BlobPool) parseTransaction(id uint64, size uint32, blob []byte) (bool, error) {
|
func (p *BlobPool) parseTransaction(id uint64, size uint32, blob []byte) (bool, error) {
|
||||||
var ptx blobTxForPool
|
var ptx blobTxForPool
|
||||||
if err := rlp.DecodeBytes(blob, &ptx); err != nil {
|
if err := rlp.DecodeBytes(blob, &ptx); err != nil {
|
||||||
tx := new(types.Transaction)
|
kind, _, _, splitErr := rlp.Split(blob)
|
||||||
if err := rlp.DecodeBytes(blob, tx); err != nil {
|
if splitErr == nil && kind == rlp.String {
|
||||||
return false, err
|
// legacy transaction is an RLP string
|
||||||
|
// while blobTxForPool is encoded as an RLP list.
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
if tx.BlobTxSidecar() == nil {
|
return false, err
|
||||||
return false, errors.New("missing blob sidecar")
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
meta := newBlobTxMeta(id, ptx.TxSize(), size, &ptx)
|
meta := newBlobTxMeta(id, ptx.TxSize(), size, &ptx)
|
||||||
if p.lookup.exists(meta.hash) {
|
if p.lookup.exists(meta.hash) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue