@@ -2,7 +2,6 @@ package txmonitor
22
33import (
44 "context"
5- "log"
65 "log/slog"
76 "time"
87
@@ -104,9 +103,11 @@ func (e *evmHelper) TraceTransaction(ctx context.Context, txHash common.Hash) (*
104103
105104// BatchReceipts retrieves multiple receipts for a list of transaction hashes.
106105func (e * evmHelper ) BatchReceipts (ctx context.Context , txHashes []common.Hash ) ([]Result , error ) {
106+ e .logger .Info ("Starting BatchReceipts" , "txHashes" , txHashes )
107107 batch := make ([]rpc.BatchElem , len (txHashes ))
108108
109109 for i , hash := range txHashes {
110+ e .logger .Debug ("Preparing batch element" , "index" , i , "hash" , hash .Hex ())
110111 batch [i ] = rpc.BatchElem {
111112 Method : "eth_getTransactionReceipt" ,
112113 Args : []interface {}{hash },
@@ -117,24 +118,31 @@ func (e *evmHelper) BatchReceipts(ctx context.Context, txHashes []common.Hash) (
117118 var receipts []Result
118119 var err error
119120 for attempts := 0 ; attempts < 50 ; attempts ++ {
121+ e .logger .Debug ("Attempting batch call" , "attempt" , attempts + 1 )
120122 // Execute the batch request
121123 err = e .client .BatchCallContext (context .Background (), batch )
122124 if err != nil {
123- log . Printf ("Batch call attempt %d failed: %v" , attempts + 1 , err )
125+ e . logger . Error ("Batch call attempt failed" , "attempt" , attempts + 1 , "error" , err )
124126 time .Sleep (1 * time .Second )
127+ } else {
128+ e .logger .Info ("Batch call attempt succeeded" , "attempt" , attempts + 1 )
129+ break
125130 }
126131 }
127132
128133 if err != nil {
134+ e .logger .Error ("All batch call attempts failed" , "error" , err )
129135 return nil , err
130136 }
131137 receipts = make ([]Result , len (batch ))
132138 for i , elem := range batch {
139+ e .logger .Debug ("Processing batch element" , "index" , i , "result" , elem .Result , "error" , elem .Error )
133140 receipts [i ].Receipt = elem .Result .(* types.Receipt )
134141 if elem .Error != nil {
135142 receipts [i ].Err = elem .Error
136143 }
137144 }
138145
146+ e .logger .Info ("BatchReceipts completed successfully" , "receipts" , receipts )
139147 return receipts , nil
140148}
0 commit comments