diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index a07c438ae..9c1ee1ce3 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -341,7 +341,7 @@ func ReadBlock(db DatabaseReader, hash common.Hash, number uint64) *types.Block if body == nil { return nil } - return types.NewBlockWithHeader(header).WithBody(body.Transactions, body.Uncles, body.IncomingReceipts) + return types.NewBlockWithHeader(header).WithBody(body.Transactions(), body.Uncles(), body.IncomingReceipts()) } // WriteBlock serializes a block into the database, header and body separately. diff --git a/core/rawdb/accessors_chain_test.go b/core/rawdb/accessors_chain_test.go index db1de0897..3b767f600 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -87,7 +87,7 @@ func TestBodyStorage(t *testing.T) { WriteBody(db, hash, 0, body) if entry := ReadBody(db, hash, 0); entry == nil { t.Fatalf("Stored body not found") - } else if types.DeriveSha(types.Transactions(entry.Transactions)) != types.DeriveSha(types.Transactions(body.Transactions)) || types.CalcUncleHash(entry.Uncles) != types.CalcUncleHash(body.Uncles) { + } else if types.DeriveSha(types.Transactions(entry.Transactions())) != types.DeriveSha(types.Transactions(body.Transactions())) || types.CalcUncleHash(entry.Uncles()) != types.CalcUncleHash(body.Uncles()) { t.Fatalf("Retrieved body mismatch: have %v, want %v", entry, body) } if entry := ReadBodyRLP(db, hash, 0); entry == nil { @@ -142,7 +142,7 @@ func TestBlockStorage(t *testing.T) { } if entry := ReadBody(db, block.Hash(), block.NumberU64()); entry == nil { t.Fatalf("Stored body not found") - } else if types.DeriveSha(types.Transactions(entry.Transactions)) != types.DeriveSha(block.Transactions()) || types.CalcUncleHash(entry.Uncles) != types.CalcUncleHash(block.Uncles()) { + } else if types.DeriveSha(types.Transactions(entry.Transactions())) != types.DeriveSha(block.Transactions()) || types.CalcUncleHash(entry.Uncles()) != types.CalcUncleHash(block.Uncles()) { t.Fatalf("Retrieved body mismatch: have %v, want %v", entry, block.Body()) } if actual, err := ReadEpochBlockNumber(db, big.NewInt(0)); err != nil { diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index 409fff167..680f17b15 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -71,7 +71,8 @@ func ReadTransaction(db DatabaseReader, hash common.Hash) (*types.Transaction, c return nil, common.Hash{}, 0, 0 } body := ReadBody(db, blockHash, blockNumber) - if body == nil || len(body.Transactions) <= int(txIndex) { + txs := body.Transactions() + if body == nil || len(txs) <= int(txIndex) { utils.Logger().Error(). Uint64("number", blockNumber). Str("hash", blockHash.Hex()). @@ -79,7 +80,7 @@ func ReadTransaction(db DatabaseReader, hash common.Hash) (*types.Transaction, c Msg("Transaction referenced missing") return nil, common.Hash{}, 0, 0 } - return body.Transactions[txIndex], blockHash, blockNumber, txIndex + return txs[txIndex], blockHash, blockNumber, txIndex } // ReadReceipt retrieves a specific transaction receipt from the database, along with