Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Added an inner context to cut getOrdersFromPeer short
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Jun 30, 2020
1 parent 94dd394 commit e2d5ba7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/ordersync/ordersync.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ func (s *Service) GetOrders(ctx context.Context, minPeers int) error {
i := 0
wg := &sync.WaitGroup{}
waitChan := make(chan struct{}, 1)
innerCtx, cancel := context.WithCancel(ctx)
defer cancel()
for _, peerID := range currentNeighbors {
if len(successfullySyncedPeers) >= minPeers {
return nil
Expand Down Expand Up @@ -329,7 +331,7 @@ func (s *Service) GetOrders(ctx context.Context, minPeers int) error {
wg.Add(1)
go func(id peer.ID) {
defer wg.Done()
if err := s.getOrdersFromPeer(ctx, id); err != nil {
if err := s.getOrdersFromPeer(innerCtx, id); err != nil {
log.WithFields(log.Fields{
"error": err.Error(),
"provider": id.Pretty(),
Expand Down

0 comments on commit e2d5ba7

Please sign in to comment.