From 1602842a6317cf26399fb2b78fa5b355ad973c09 Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Sat, 5 Feb 2022 20:11:56 +0100 Subject: [PATCH] fixed api.blockWithSenders (#3435) * fix * fix 2 * fixed api.blockWithSenders * removed white space * pretty --- core/types/receipt.go | 4 ++-- ethdb/privateapi/ethbackend.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index 68dc6ab98..554513505 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -432,10 +432,10 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) { func (r Receipts) DeriveFields(hash common.Hash, number uint64, txs Transactions, senders []common.Address) error { logIndex := uint(0) // logIdx is unique within the block and starts from 0 if len(txs) != len(r) { - return errors.New("transaction and receipt count mismatch") + return fmt.Errorf("transaction and receipt count mismatch, tx count = %d, receipts count = %d", len(txs), len(r)) } if len(senders) != len(txs) { - return errors.New("transaction and senders count mismatch") + return fmt.Errorf("transaction and senders count mismatch, tx count = %d, receipts count = %d", len(txs), len(r)) } for i := 0; i < len(r); i++ { // The transaction type and hash can be retrieved from the transaction itself diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index d43667226..ce99eeaf4 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -216,8 +216,8 @@ func (s *EthBackendServer) Block(ctx context.Context, req *remote.BlockRequest) return nil, err } sendersBytes := make([]byte, 20*len(senders)) - for i := range senders { - sendersBytes = append(sendersBytes, senders[i][:]...) + for i, sender := range senders { + copy(sendersBytes[i*20:], sender[:]) } return &remote.BlockReply{BlockRlp: blockRlp, Senders: sendersBytes}, nil }