File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ func DecodeLogs(chainId string, logs []Log) []*DecodedLog {
4444 decodedLogs := make ([]* DecodedLog , len (logs ))
4545 abiCache := make (map [string ]* abi.ABI )
4646
47- decodeLogFunc := func (eventLog * Log ) * DecodedLog {
47+ decodeLogFunc := func (eventLog * Log , mut * sync. Mutex ) * DecodedLog {
4848 decodedLog := DecodedLog {Log : * eventLog }
49- abi := GetABIForContractWithCache (chainId , eventLog .Address , abiCache )
49+ abi := GetABIForContractWithCache (chainId , eventLog .Address , abiCache , mut )
5050 if abi == nil {
5151 return & decodedLog
5252 }
@@ -63,13 +63,14 @@ func DecodeLogs(chainId string, logs []Log) []*DecodedLog {
6363 }
6464
6565 var wg sync.WaitGroup
66+ var mut sync.Mutex
6667 for idx , eventLog := range logs {
6768 wg .Add (1 )
68- go func (idx int , eventLog Log ) {
69+ go func (idx int , eventLog Log , mut * sync. Mutex ) {
6970 defer wg .Done ()
70- decodedLog := decodeLogFunc (& eventLog )
71+ decodedLog := decodeLogFunc (& eventLog , mut )
7172 decodedLogs [idx ] = decodedLog
72- }(idx , eventLog )
73+ }(idx , eventLog , & mut )
7374 }
7475 wg .Wait ()
7576 return decodedLogs
You can’t perform that action at this time.
0 commit comments