mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
eth/protocols/eth: simplify
This commit is contained in:
parent
5943631173
commit
268f33ac95
2 changed files with 4 additions and 20 deletions
|
|
@ -19,7 +19,6 @@ package eth
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"iter"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
@ -63,19 +62,8 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
|
|||
return s.ListEnd()
|
||||
}
|
||||
|
||||
// EncodeRLP writes the network encoding of receipts.
|
||||
func (r *Receipt) EncodeRLP(_w io.Writer) error {
|
||||
w := rlp.NewEncoderBuffer(_w)
|
||||
list := w.List()
|
||||
w.WriteUint64(uint64(r.TxType))
|
||||
w.WriteBytes(r.PostStateOrStatus)
|
||||
w.WriteUint64(r.GasUsed)
|
||||
w.Write(r.Logs)
|
||||
w.ListEnd(list)
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
// encodeStorage writes the network encoding of receipts.
|
||||
// encodeStorage writes the storage encoding, i.e. the result matches
|
||||
// types.ReceiptForStorage.
|
||||
func (r *Receipt) encodeStorage(w *rlp.EncoderBuffer) {
|
||||
list := w.List()
|
||||
w.WriteBytes(r.PostStateOrStatus)
|
||||
|
|
|
|||
|
|
@ -66,18 +66,14 @@ func TestTransformReceipts(t *testing.T) {
|
|||
encBlockBody, _ := rlp.EncodeToBytes(blockBody)
|
||||
|
||||
// convert from storage encoding to network encoding
|
||||
have, err := blockReceiptsToNetwork(in, encBlockBody)
|
||||
network, err := blockReceiptsToNetwork(in, encBlockBody)
|
||||
if err != nil {
|
||||
t.Fatalf("test[%d]: blockReceiptsToNetwork error: %v", i, err)
|
||||
}
|
||||
out, _ := rlp.EncodeToBytes(test.output)
|
||||
if !bytes.Equal(have, out) {
|
||||
t.Fatalf("test[%d]: blockReceiptsToNetwork mismatch\nhave: %x\nwant: %x\n in: %x", i, out, have, in)
|
||||
}
|
||||
|
||||
// parse as Receipts response list from network encoding
|
||||
var rl ReceiptList69
|
||||
if err := rlp.DecodeBytes(out, &rl); err != nil {
|
||||
if err := rlp.DecodeBytes(network, &rl); err != nil {
|
||||
t.Fatalf("test[%d]: can't decode network receipts: %v", i, err)
|
||||
}
|
||||
storageEnc := rl.toStorageReceiptsRLP()
|
||||
|
|
|
|||
Loading…
Reference in a new issue