Export IPLD encoders #29
@ -38,8 +38,8 @@ func EncodeHeader(header *types.Header) (IPLD, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeTx converts a *types.Transaction to an IPLD node
|
// EncodeTx converts a *types.Transaction to an IPLD node
|
||||||
func encodeTx(tx *types.Transaction) (IPLD, error) {
|
func EncodeTx(tx *types.Transaction) (IPLD, error) {
|
||||||
txRaw, err := tx.MarshalBinary()
|
txRaw, err := tx.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,8 +54,8 @@ func encodeTx(tx *types.Transaction) (IPLD, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeReceipt converts a types.Receipt to an IPLD node
|
// EncodeReceipt converts a types.Receipt to an IPLD node
|
||||||
func encodeReceipt(receipt *types.Receipt) (IPLD, error) {
|
func EncodeReceipt(receipt *types.Receipt) (IPLD, error) {
|
||||||
rctRaw, err := receipt.MarshalBinary()
|
rctRaw, err := receipt.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -70,8 +70,8 @@ func encodeReceipt(receipt *types.Receipt) (IPLD, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeLog converts a Log to an IPLD node
|
// EncodeLog converts a Log to an IPLD node
|
||||||
func encodeLog(log *types.Log) (IPLD, error) {
|
func EncodeLog(log *types.Log) (IPLD, error) {
|
||||||
logRaw, err := rlp.EncodeToBytes(log)
|
logRaw, err := rlp.EncodeToBytes(log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -86,7 +86,7 @@ func encodeLog(log *types.Log) (IPLD, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeWithdrawal(w *types.Withdrawal) (IPLD, error) {
|
func EncodeWithdrawal(w *types.Withdrawal) (IPLD, error) {
|
||||||
wRaw, err := rlp.EncodeToBytes(w)
|
wRaw, err := rlp.EncodeToBytes(w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -44,7 +44,7 @@ func FromBlockAndReceipts(block *types.Block, receipts []*types.Receipt) ([]IPLD
|
|||||||
func processTransactions(txs []*types.Transaction) ([]IPLD, error) {
|
func processTransactions(txs []*types.Transaction) ([]IPLD, error) {
|
||||||
var ethTxNodes []IPLD
|
var ethTxNodes []IPLD
|
||||||
for _, tx := range txs {
|
for _, tx := range txs {
|
||||||
ethTx, err := encodeTx(tx)
|
ethTx, err := EncodeTx(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ func processTransactions(txs []*types.Transaction) ([]IPLD, error) {
|
|||||||
func processWithdrawals(withdrawals []*types.Withdrawal) ([]IPLD, error) {
|
func processWithdrawals(withdrawals []*types.Withdrawal) ([]IPLD, error) {
|
||||||
var withdrawalNodes []IPLD
|
var withdrawalNodes []IPLD
|
||||||
for _, withdrawal := range withdrawals {
|
for _, withdrawal := range withdrawals {
|
||||||
ethW, err := encodeWithdrawal(withdrawal)
|
ethW, err := EncodeWithdrawal(withdrawal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ func processReceiptsAndLogs(rcts []*types.Receipt) ([]IPLD, [][]IPLD, error) {
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ethRct, err := encodeReceipt(rct)
|
ethRct, err := EncodeReceipt(rct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ func processReceiptsAndLogs(rcts []*types.Receipt) ([]IPLD, [][]IPLD, error) {
|
|||||||
func processLogs(logs []*types.Log) ([]IPLD, error) {
|
func processLogs(logs []*types.Log) ([]IPLD, error) {
|
||||||
logNodes := make([]IPLD, len(logs))
|
logNodes := make([]IPLD, len(logs))
|
||||||
for idx, log := range logs {
|
for idx, log := range logs {
|
||||||
logNode, err := encodeLog(log)
|
logNode, err := EncodeLog(log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user