From cd3d9f27cfdf37e7e309cebaa23fb486bb371046 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Mon, 7 Sep 2020 21:02:30 -0500 Subject: [PATCH] cleanup --- pkg/snapshot/service.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/snapshot/service.go b/pkg/snapshot/service.go index b4bb1ab..c967a90 100644 --- a/pkg/snapshot/service.go +++ b/pkg/snapshot/service.go @@ -31,7 +31,7 @@ import ( "github.com/sirupsen/logrus" "github.com/vulcanize/ipfs-blockchain-watcher/pkg/postgres" - iter "github.com/vulcanize/go-eth-state-node-iterator/pkg/iterator" + iter "github.com/vulcanize/go-eth-state-node-iterator/iterator" ) var ( @@ -201,12 +201,8 @@ func (s *Service) createSnapshot(it trie.NodeIterator, headerID int64) error { // Full-trie snapshot using goroutines func (s *Service) createSnapshotAsync(tree state.Trie, headerID int64, workers uint) error { errors := make(chan error) - finished := make(chan bool) var wg sync.WaitGroup - - iters := iter.SubtrieIterators(tree, workers) - - for _, it := range iters { + for _, it := range iter.SubtrieIterators(tree, workers) { wg.Add(1) go func() { defer wg.Done() @@ -215,15 +211,12 @@ func (s *Service) createSnapshotAsync(tree state.Trie, headerID int64, workers u } }() } - go func() { - defer close(finished) + defer close(errors) wg.Wait() }() select { - case <-finished: - break case err := <-errors: return err }