rawdb: change DeriveField to DeriveFields

pull/29670/head
pengin7384 3 months ago
parent 9dbb4830c1
commit 9a45917dab
  1. 2
      core/rawdb/accessors_indexes.go
  2. 6
      core/types/receipt.go
  3. 4
      core/types/receipt_test.go

@ -179,7 +179,7 @@ func ReadReceipt(db ethdb.Reader, txHash common.Hash, config *params.ChainConfig
logIndex += uint(len(receipts[i].Logs)) logIndex += uint(len(receipts[i].Logs))
} }
if err := targetReceipt.DeriveField(signer, blockHash, *blockNumber, blockHeader.BaseFee, blobGasPrice, uint(txIndex), gasUsed, logIndex, blockBody.Transactions[txIndex]); err != nil { if err := targetReceipt.DeriveFields(signer, blockHash, *blockNumber, blockHeader.BaseFee, blobGasPrice, uint(txIndex), gasUsed, logIndex, blockBody.Transactions[txIndex]); err != nil {
log.Error("Failed to derive the receipt fields", "txHash", txHash, "err", err) log.Error("Failed to derive the receipt fields", "txHash", txHash, "err", err)
return nil, common.Hash{}, 0, 0 return nil, common.Hash{}, 0, 0
} }

@ -117,9 +117,9 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt {
return r return r
} }
// DeriveField fills the receipt with their computed fields based on consensus // DeriveFields fills the receipt with their computed fields based on consensus
// data and contextual infos like containing block and transactions. // data and contextual infos like containing block and transactions.
func (r *Receipt) DeriveField(signer Signer, hash common.Hash, number uint64, baseFee *big.Int, blobGasPrice *big.Int, txIndex uint, gasUsed uint64, firstLogIndex uint, tx *Transaction) error { func (r *Receipt) DeriveFields(signer Signer, hash common.Hash, number uint64, baseFee *big.Int, blobGasPrice *big.Int, txIndex uint, gasUsed uint64, firstLogIndex uint, tx *Transaction) error {
// The transaction type and hash can be retrieved from the transaction itself // The transaction type and hash can be retrieved from the transaction itself
r.Type = tx.Type() r.Type = tx.Type()
r.TxHash = tx.Hash() r.TxHash = tx.Hash()
@ -378,7 +378,7 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
} else { } else {
gasUsed = rs[i].CumulativeGasUsed - rs[i-1].CumulativeGasUsed gasUsed = rs[i].CumulativeGasUsed - rs[i-1].CumulativeGasUsed
} }
if err := rs[i].DeriveField(signer, hash, number, baseFee, blobGasPrice, uint(i), gasUsed, logIndex, txs[i]); err != nil { if err := rs[i].DeriveFields(signer, hash, number, baseFee, blobGasPrice, uint(i), gasUsed, logIndex, txs[i]); err != nil {
return err return err
} }
logIndex += uint(len(rs[i].Logs)) logIndex += uint(len(rs[i].Logs))

@ -320,9 +320,9 @@ func TestDeriveField(t *testing.T) {
} else { } else {
gasUsed = derivedReceipts[i].CumulativeGasUsed - derivedReceipts[i-1].CumulativeGasUsed gasUsed = derivedReceipts[i].CumulativeGasUsed - derivedReceipts[i-1].CumulativeGasUsed
} }
err := derivedReceipts[i].DeriveField(signer, blockHash, blockNumber.Uint64(), basefee, blobGasPrice, uint(i), gasUsed, logIndex, txs[i]) err := derivedReceipts[i].DeriveFields(signer, blockHash, blockNumber.Uint64(), basefee, blobGasPrice, uint(i), gasUsed, logIndex, txs[i])
if err != nil { if err != nil {
t.Fatalf("DeriveField(...) = %v, want <nil>", err) t.Fatalf("DeriveFields(...) = %v, want <nil>", err)
} }
logIndex += uint(len(derivedReceipts[i].Logs)) logIndex += uint(len(derivedReceipts[i].Logs))

Loading…
Cancel
Save