fix error caused by 2718 by using MarshalBinary instead of EncodeRLP methods
This commit is contained in:
parent
b653dd7ce4
commit
6948bd70e5
@ -22,7 +22,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
node "github.com/ipfs/go-ipld-format"
|
node "github.com/ipfs/go-ipld-format"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
@ -44,18 +43,18 @@ var _ node.Node = (*EthReceipt)(nil)
|
|||||||
|
|
||||||
// NewReceipt converts a types.ReceiptForStorage to an EthReceipt IPLD node
|
// NewReceipt converts a types.ReceiptForStorage to an EthReceipt IPLD node
|
||||||
func NewReceipt(receipt *types.Receipt) (*EthReceipt, error) {
|
func NewReceipt(receipt *types.Receipt) (*EthReceipt, error) {
|
||||||
receiptRLP, err := rlp.EncodeToBytes(receipt)
|
rctRaw, err := receipt.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c, err := RawdataToCid(MEthTxReceipt, receiptRLP, mh.KECCAK_256)
|
c, err := RawdataToCid(MEthTxReceipt, rctRaw, mh.KECCAK_256)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &EthReceipt{
|
return &EthReceipt{
|
||||||
Receipt: receipt,
|
Receipt: receipt,
|
||||||
cid: c,
|
cid: c,
|
||||||
rawdata: receiptRLP,
|
rawdata: rctRaw,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +65,8 @@ func NewReceipt(receipt *types.Receipt) (*EthReceipt, error) {
|
|||||||
// DecodeEthReceipt takes a cid and its raw binary data
|
// DecodeEthReceipt takes a cid and its raw binary data
|
||||||
// from IPFS and returns an EthTx object for further processing.
|
// from IPFS and returns an EthTx object for further processing.
|
||||||
func DecodeEthReceipt(c cid.Cid, b []byte) (*EthReceipt, error) {
|
func DecodeEthReceipt(c cid.Cid, b []byte) (*EthReceipt, error) {
|
||||||
var r *types.Receipt
|
r := new(types.Receipt)
|
||||||
if err := rlp.DecodeBytes(b, r); err != nil {
|
if err := r.UnmarshalBinary(b); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &EthReceipt{
|
return &EthReceipt{
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
node "github.com/ipfs/go-ipld-format"
|
node "github.com/ipfs/go-ipld-format"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
@ -46,18 +45,18 @@ var _ node.Node = (*EthTx)(nil)
|
|||||||
|
|
||||||
// NewEthTx converts a *types.Transaction to an EthTx IPLD node
|
// NewEthTx converts a *types.Transaction to an EthTx IPLD node
|
||||||
func NewEthTx(tx *types.Transaction) (*EthTx, error) {
|
func NewEthTx(tx *types.Transaction) (*EthTx, error) {
|
||||||
txRLP, err := rlp.EncodeToBytes(tx)
|
txRaw, err := tx.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c, err := RawdataToCid(MEthTx, txRLP, mh.KECCAK_256)
|
c, err := RawdataToCid(MEthTx, txRaw, mh.KECCAK_256)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &EthTx{
|
return &EthTx{
|
||||||
Transaction: tx,
|
Transaction: tx,
|
||||||
cid: c,
|
cid: c,
|
||||||
rawdata: txRLP,
|
rawdata: txRaw,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +67,8 @@ func NewEthTx(tx *types.Transaction) (*EthTx, error) {
|
|||||||
// DecodeEthTx takes a cid and its raw binary data
|
// DecodeEthTx takes a cid and its raw binary data
|
||||||
// from IPFS and returns an EthTx object for further processing.
|
// from IPFS and returns an EthTx object for further processing.
|
||||||
func DecodeEthTx(c cid.Cid, b []byte) (*EthTx, error) {
|
func DecodeEthTx(c cid.Cid, b []byte) (*EthTx, error) {
|
||||||
var t *types.Transaction
|
t := new(types.Transaction)
|
||||||
if err := rlp.DecodeBytes(b, t); err != nil {
|
if err := t.UnmarshalBinary(b); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &EthTx{
|
return &EthTx{
|
||||||
|
Loading…
Reference in New Issue
Block a user