File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
22
22
"errors"
23
23
"fmt"
24
24
"math/big"
25
+ "sort"
25
26
"strconv"
26
27
27
28
"github.com/ethereum/go-ethereum"
@@ -478,13 +479,16 @@ func (t *Transaction) getLogs(ctx context.Context) (*[]*Log, error) {
478
479
if err != nil {
479
480
return nil , err
480
481
}
481
- ret := make ([]* Log , 0 , len (logs ))
482
- for _ , log := range logs {
482
+ var ret []* Log
483
+ // Select tx logs from all block logs
484
+ ix := sort .Search (len (logs ), func (i int ) bool { return uint64 (logs [i ].TxIndex ) == t .index })
485
+ for ix < len (logs ) && uint64 (logs [ix ].TxIndex ) == t .index {
483
486
ret = append (ret , & Log {
484
487
r : t .r ,
485
488
transaction : t ,
486
- log : log ,
489
+ log : logs [ ix ] ,
487
490
})
491
+ ix ++
488
492
}
489
493
return & ret , nil
490
494
}
You can’t perform that action at this time.
0 commit comments