mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
eth/filters: add WaitGroup to serveMatcher
This commit is contained in:
parent
189cd0c438
commit
0957393047
1 changed files with 10 additions and 3 deletions
|
|
@ -19,6 +19,7 @@ package filters
|
|||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -128,10 +129,13 @@ func (f *Filter) Find(ctx context.Context) (logs []*types.Log, err error) {
|
|||
|
||||
// serveMatcher serves the bloomBits matcher by fetching the requested vectors
|
||||
// through the filter backend
|
||||
func (f *Filter) serveMatcher(ctx context.Context, stop chan struct{}) chan error {
|
||||
func (f *Filter) serveMatcher(ctx context.Context, stop chan struct{}, wg *sync.WaitGroup) chan error {
|
||||
errChn := make(chan error)
|
||||
wg.Add(10)
|
||||
for i := 0; i < 10; i++ {
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
|
||||
for {
|
||||
b, s := f.matcher.NextRequest(stop)
|
||||
if s == nil {
|
||||
|
|
@ -187,9 +191,12 @@ func (f *Filter) getLogs(ctx context.Context, start, end uint64) (logs []*types.
|
|||
}
|
||||
|
||||
stop := make(chan struct{})
|
||||
defer close(stop)
|
||||
var wg sync.WaitGroup
|
||||
matches := f.matcher.GetMatches(start, e, stop)
|
||||
errChn := f.serveMatcher(ctx, stop)
|
||||
errChn := f.serveMatcher(ctx, stop, &wg)
|
||||
|
||||
defer wg.Wait()
|
||||
defer close(stop)
|
||||
|
||||
loop:
|
||||
for {
|
||||
|
|
|
|||
Loading…
Reference in a new issue