Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/types: remove LogForStorage type #23173

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
core/types: rm LogForStorage type
  • Loading branch information
s1na committed Jul 7, 2021
commit 1f7b9489ec90c9cb78aae39f291b06a53fc0ad93
28 changes: 0 additions & 28 deletions core/types/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ type rlpLog struct {
Data []byte
}

// rlpStorageLog is the storage encoding of a log.
type rlpStorageLog rlpLog

// EncodeRLP implements rlp.Encoder.
func (l *Log) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, rlpLog{Address: l.Address, Topics: l.Topics, Data: l.Data})
Expand All @@ -85,28 +82,3 @@ func (l *Log) DecodeRLP(s *rlp.Stream) error {
}
return err
}

// LogForStorage is a wrapper around a Log that flattens and parses the entire content of
// a log including non-consensus fields.
type LogForStorage Log

// EncodeRLP implements rlp.Encoder.
func (l *LogForStorage) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, rlpStorageLog{
Address: l.Address,
Topics: l.Topics,
Data: l.Data,
})
}

// DecodeRLP implements rlp.Decoder.
//
// Note some redundant fields(e.g. block number, tx hash etc) will be assembled later.
func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error {
var dec rlpStorageLog
if err := s.Decode(&dec); err != nil {
return err
}
*l = LogForStorage{Address: dec.Address, Topics: dec.Topics, Data: dec.Data}
return nil
}
7 changes: 2 additions & 5 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type receiptRLP struct {
type storedReceiptRLP struct {
PostStateOrStatus []byte
CumulativeGasUsed uint64
Logs []*LogForStorage
Logs []*Log
}

// NewReceipt creates a barebone transaction receipt, copying the init fields.
Expand Down Expand Up @@ -217,10 +217,7 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error {
enc := &storedReceiptRLP{
PostStateOrStatus: (*Receipt)(r).statusEncoding(),
CumulativeGasUsed: r.CumulativeGasUsed,
Logs: make([]*LogForStorage, len(r.Logs)),
}
for i, log := range r.Logs {
enc.Logs[i] = (*LogForStorage)(log)
Logs: r.Logs,
}
return rlp.Encode(w, enc)
}
Expand Down