aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/receipt.go
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-02-21 21:14:35 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-02-21 21:14:35 +0800
commit7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a (patch)
treea6eb7b42652916da18091879974f0f513dd19e3d /core/types/receipt.go
parent8577b5b020d963ef9972981bbfc62b8930d3e9c9 (diff)
downloadgo-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.tar
go-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.tar.gz
go-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.tar.bz2
go-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.tar.lz
go-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.tar.xz
go-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.tar.zst
go-tangerine-7fd0ccaa68cbc8e3f4fc59d3b99ba5067ba7c73a.zip
core: remove unnecessary fields in logs, receipts and tx lookups (#17106)
* core: remove unnecessary fields in log * core: bump blockchain database version * core, les: remove unnecessary fields in txlookup * eth: print db version explicitly * core/rawdb: drop txlookup entry struct wrapper
Diffstat (limited to 'core/types/receipt.go')
-rw-r--r--core/types/receipt.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/core/types/receipt.go b/core/types/receipt.go
index 3d1fc95aa..ac1ebe349 100644
--- a/core/types/receipt.go
+++ b/core/types/receipt.go
@@ -72,9 +72,20 @@ type receiptRLP struct {
Logs []*Log
}
+// receiptStorageRLP is the storage encoding of a receipt.
type receiptStorageRLP struct {
PostStateOrStatus []byte
CumulativeGasUsed uint64
+ TxHash common.Hash
+ ContractAddress common.Address
+ Logs []*LogForStorage
+ GasUsed uint64
+}
+
+// LegacyReceiptStorageRLP is the previous storage encoding of a receipt including some unnecessary fields.
+type LegacyReceiptStorageRLP struct {
+ PostStateOrStatus []byte
+ CumulativeGasUsed uint64
Bloom Bloom
TxHash common.Hash
ContractAddress common.Address
@@ -159,7 +170,6 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error {
enc := &receiptStorageRLP{
PostStateOrStatus: (*Receipt)(r).statusEncoding(),
CumulativeGasUsed: r.CumulativeGasUsed,
- Bloom: r.Bloom,
TxHash: r.TxHash,
ContractAddress: r.ContractAddress,
Logs: make([]*LogForStorage, len(r.Logs)),
@@ -176,17 +186,28 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error {
func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error {
var dec receiptStorageRLP
if err := s.Decode(&dec); err != nil {
- return err
+ var sdec LegacyReceiptStorageRLP
+ if err := s.Decode(&sdec); err != nil {
+ return err
+ }
+ dec.PostStateOrStatus = common.CopyBytes(sdec.PostStateOrStatus)
+ dec.CumulativeGasUsed = sdec.CumulativeGasUsed
+ dec.TxHash = sdec.TxHash
+ dec.ContractAddress = sdec.ContractAddress
+ dec.Logs = sdec.Logs
+ dec.GasUsed = sdec.GasUsed
}
if err := (*Receipt)(r).setStatus(dec.PostStateOrStatus); err != nil {
return err
}
// Assign the consensus fields
- r.CumulativeGasUsed, r.Bloom = dec.CumulativeGasUsed, dec.Bloom
+ r.CumulativeGasUsed = dec.CumulativeGasUsed
r.Logs = make([]*Log, len(dec.Logs))
for i, log := range dec.Logs {
r.Logs[i] = (*Log)(log)
}
+
+ r.Bloom = CreateBloom(Receipts{(*Receipt)(r)})
// Assign the implementation fields
r.TxHash, r.ContractAddress, r.GasUsed = dec.TxHash, dec.ContractAddress, dec.GasUsed
return nil