mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
core/types: maintain tx size cache in WithoutBlobTxSidecar
This commit is contained in:
parent
11f1b1f1da
commit
69fe54b2e5
1 changed files with 6 additions and 2 deletions
|
|
@ -449,14 +449,18 @@ func (tx *Transaction) BlobGasFeeCapIntCmp(other *big.Int) int {
|
||||||
// WithoutBlobTxSidecar returns a copy of tx with the blob sidecar removed.
|
// WithoutBlobTxSidecar returns a copy of tx with the blob sidecar removed.
|
||||||
func (tx *Transaction) WithoutBlobTxSidecar() *Transaction {
|
func (tx *Transaction) WithoutBlobTxSidecar() *Transaction {
|
||||||
blobtx, ok := tx.inner.(*BlobTx)
|
blobtx, ok := tx.inner.(*BlobTx)
|
||||||
if !ok {
|
if !ok || blobtx.Sidecar == nil {
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
cpy := &Transaction{
|
cpy := &Transaction{
|
||||||
inner: blobtx.withoutSidecar(),
|
inner: blobtx.withoutSidecar(),
|
||||||
time: tx.time,
|
time: tx.time,
|
||||||
}
|
}
|
||||||
// Note: tx.size cache not carried over because the sidecar is included in size!
|
if size := tx.size.Load(); size != 0 {
|
||||||
|
// The tx had a sidecar before, so we need to subtract it from the size.
|
||||||
|
scSize := rlp.ListSize(blobtx.Sidecar.encodedSize())
|
||||||
|
cpy.size.Store(size - scSize)
|
||||||
|
}
|
||||||
if h := tx.hash.Load(); h != nil {
|
if h := tx.hash.Load(); h != nil {
|
||||||
cpy.hash.Store(h)
|
cpy.hash.Store(h)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue