@@ -610,26 +610,36 @@ func (api *PrivateDebugAPI) GetAccessibleState(from, to rpc.BlockNumber) (uint64
610
610
611
611
// GetBlockReceipts returns all transaction receipts of the specified block.
612
612
func (api * PrivateDebugAPI ) GetBlockReceipts (ctx context.Context , blockHash common.Hash ) ([]map [string ]interface {}, error ) {
613
- if receipts := api .eth .blockchain .GetReceiptsByHash (blockHash ); receipts != nil {
614
- if block := api .eth .blockchain .GetBlockByHash (blockHash ); block != nil {
615
- txs := block .Transactions ()
616
- if len (txs ) != len (receipts ) {
617
- return nil , fmt .Errorf ("txs length doesn't equal to receipts' length" )
618
- }
619
-
620
- txReceipts := make ([]map [string ]interface {}, 0 , len (txs ))
621
- blockNumber := block .Header ().Number
622
- for idx , receipt := range receipts {
623
- tx := txs [idx ]
624
- fields , err := ethapi .ToTransactionReceipt (ctx , api .eth .APIBackend , tx , receipt , blockHash , tx .Hash (), blockNumber .Uint64 (), uint64 (idx ))
625
- if err != nil {
626
- return nil , err
627
- }
628
- txReceipts = append (txReceipts , fields )
629
- }
630
-
631
- return txReceipts , nil
613
+ block := api .eth .blockchain .GetBlockByHash (blockHash )
614
+ if block == nil {
615
+ return nil , errors .New ("block not found" )
616
+ }
617
+ blockNumber := block .Header ().Number
618
+ receipts := api .eth .blockchain .GetReceiptsByHash (blockHash )
619
+ if receipts == nil {
620
+ return nil , errors .New ("receipts not found" )
621
+ }
622
+ txs := block .Transactions ()
623
+ if len (txs ) != len (receipts ) {
624
+ return nil , fmt .Errorf ("txs length doesn't equal to receipts' length" )
625
+ }
626
+ txReceipts := make ([]map [string ]interface {}, 0 , len (txs ))
627
+ for idx , receipt := range receipts {
628
+ tx := txs [idx ]
629
+ fields , err := ethapi .ToTransactionReceipt (ctx , api .eth .APIBackend , tx , receipt , blockHash , tx .Hash (), blockNumber .Uint64 (), uint64 (idx ))
630
+ if err != nil {
631
+ return nil , err
632
+ }
633
+ txReceipts = append (txReceipts , fields )
634
+ }
635
+ receipt := rawdb .ReadBorReceipt (api .eth .chainDb , blockHash , blockNumber .Uint64 ())
636
+ if receipt != nil {
637
+ tx , _ , _ , _ := rawdb .ReadBorTransaction (api .eth .chainDb , receipt .TxHash )
638
+ fields , err := ethapi .ToTransactionReceipt (ctx , api .eth .APIBackend , tx , receipt , blockHash , receipt .TxHash , blockNumber .Uint64 (), uint64 (receipt .TransactionIndex ))
639
+ if err != nil {
640
+ return nil , err
632
641
}
642
+ txReceipts = append (txReceipts , fields )
633
643
}
634
- return nil , errors . New ( "unknown receipts" )
644
+ return txReceipts , nil
635
645
}
0 commit comments