mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
eth/protocols/eth: move EncodeForStorage below constructor
conventionally, the constructor definition should be as close as possible to the type definition
This commit is contained in:
parent
98a5a26082
commit
ca0c5b9d72
1 changed files with 22 additions and 22 deletions
|
|
@ -140,6 +140,28 @@ type ReceiptList struct {
|
|||
items rlp.RawList[Receipt]
|
||||
}
|
||||
|
||||
// NewReceiptList creates a receipt list.
|
||||
// This is slow, and exists for testing purposes.
|
||||
func NewReceiptList(trs []*types.Receipt) *ReceiptList {
|
||||
rl := new(ReceiptList)
|
||||
for _, tr := range trs {
|
||||
r := newReceipt(tr)
|
||||
encoded, _ := rlp.EncodeToBytes(&r)
|
||||
rl.items.AppendRaw(encoded)
|
||||
}
|
||||
return rl
|
||||
}
|
||||
|
||||
// DecodeRLP decodes a list receipts from the network format.
|
||||
func (rl *ReceiptList) DecodeRLP(s *rlp.Stream) error {
|
||||
return rl.items.DecodeRLP(s)
|
||||
}
|
||||
|
||||
// EncodeRLP encodes the list into the network format of eth/69.
|
||||
func (rl *ReceiptList) EncodeRLP(w io.Writer) error {
|
||||
return rl.items.EncodeRLP(w)
|
||||
}
|
||||
|
||||
// EncodeForStorage encodes a list of receipts for the database.
|
||||
// It only strips the first element (TxType) from each receipt's
|
||||
// raw RLP without the actual decoding and re-encoding.
|
||||
|
|
@ -169,28 +191,6 @@ func (rl *ReceiptList) EncodeForStorage() (rlp.RawValue, error) {
|
|||
return out.Bytes(), nil
|
||||
}
|
||||
|
||||
// NewReceiptList creates a receipt list.
|
||||
// This is slow, and exists for testing purposes.
|
||||
func NewReceiptList(trs []*types.Receipt) *ReceiptList {
|
||||
rl := new(ReceiptList)
|
||||
for _, tr := range trs {
|
||||
r := newReceipt(tr)
|
||||
encoded, _ := rlp.EncodeToBytes(&r)
|
||||
rl.items.AppendRaw(encoded)
|
||||
}
|
||||
return rl
|
||||
}
|
||||
|
||||
// DecodeRLP decodes a list receipts from the network format.
|
||||
func (rl *ReceiptList) DecodeRLP(s *rlp.Stream) error {
|
||||
return rl.items.DecodeRLP(s)
|
||||
}
|
||||
|
||||
// EncodeRLP encodes the list into the network format of eth/69.
|
||||
func (rl *ReceiptList) EncodeRLP(w io.Writer) error {
|
||||
return rl.items.EncodeRLP(w)
|
||||
}
|
||||
|
||||
// Derivable returns a DerivableList, which can be used to decode
|
||||
func (rl *ReceiptList) Derivable() types.DerivableList {
|
||||
var bloomBuf [6]byte
|
||||
|
|
|
|||
Loading…
Reference in a new issue