mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +00:00
add bor receipts
This commit is contained in:
parent
8efd908e58
commit
5ab59960ed
2 changed files with 19 additions and 4 deletions
|
|
@ -78,8 +78,8 @@ func (ec *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Blo
|
||||||
return ec.getBlock(ctx, "eth_getBlockByHash", hash, true)
|
return ec.getBlock(ctx, "eth_getBlockByHash", hash, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *Client) TransactionReceiptsInBlockByBlockNumber(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error) {
|
func (ec *Client) TransactionReceiptsInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error) {
|
||||||
var rs []*types.Receipt
|
var rs []map[string]interface{}
|
||||||
err := ec.c.CallContext(ctx, &rs, "eth_getTransactionReceiptsByBlock", blockNrOrHash)
|
err := ec.c.CallContext(ctx, &rs, "eth_getTransactionReceiptsByBlock", blockNrOrHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -544,8 +544,21 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
txs := block.Transactions()
|
txs := block.Transactions()
|
||||||
|
|
||||||
|
var txHash common.Hash
|
||||||
|
|
||||||
|
borReceipt := rawdb.ReadBorReceipt(s.b.ChainDb(), block.Hash(), block.NumberU64())
|
||||||
|
if borReceipt != nil {
|
||||||
|
receipts = append(receipts, borReceipt)
|
||||||
|
txHash = types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash()))
|
||||||
|
if txHash != (common.Hash{}) {
|
||||||
|
borTx, _, _, _, _ := s.b.GetBorBlockTransactionWithBlockHash(ctx, txHash, block.Hash())
|
||||||
|
txs = append(txs, borTx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(txs) != len(receipts) {
|
if len(txs) != len(receipts) {
|
||||||
return nil, fmt.Errorf("txs length doesn't equal to receipts' length")
|
return nil, fmt.Errorf("txs length doesn't equal to receipts' length", len(txs), len(receipts))
|
||||||
}
|
}
|
||||||
|
|
||||||
txReceipts := make([]map[string]interface{}, 0, len(txs))
|
txReceipts := make([]map[string]interface{}, 0, len(txs))
|
||||||
|
|
@ -581,11 +594,13 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context,
|
||||||
if receipt.Logs == nil {
|
if receipt.Logs == nil {
|
||||||
fields["logs"] = [][]*types.Log{}
|
fields["logs"] = [][]*types.Log{}
|
||||||
}
|
}
|
||||||
|
if borReceipt != nil {
|
||||||
|
fields["transactionHash"] = txHash
|
||||||
|
}
|
||||||
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
|
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
|
||||||
if receipt.ContractAddress != (common.Address{}) {
|
if receipt.ContractAddress != (common.Address{}) {
|
||||||
fields["contractAddress"] = receipt.ContractAddress
|
fields["contractAddress"] = receipt.ContractAddress
|
||||||
}
|
}
|
||||||
fields = s.appendRPCMarshalBorTransaction(ctx, block, fields, true)
|
|
||||||
|
|
||||||
txReceipts = append(txReceipts, fields)
|
txReceipts = append(txReceipts, fields)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue