Skip to content

Commit 09ec90a

Browse files
committed
fixup! [GH-659] Basic protocol version change handling.
1 parent 0b85d2a commit 09ec90a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

nil/internal/collate/syncer.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,18 @@ func (s *Syncer) shardIsEmpty(ctx context.Context) (bool, error) {
8484
return block == nil, nil
8585
}
8686

87-
func (s *Syncer) WaitComplete() {
88-
s.waitForSync.Wait()
87+
func (s *Syncer) WaitComplete(ctx context.Context) error {
88+
c := make(chan struct{}, 1)
89+
go func() {
90+
defer close(c)
91+
s.waitForSync.Wait()
92+
}()
93+
select {
94+
case <-ctx.Done():
95+
return ctx.Err()
96+
case <-c:
97+
return nil
98+
}
8999
}
90100

91101
func (s *Syncer) getLocalVersion(ctx context.Context) (*NodeVersion, error) {

nil/services/nilservice/service.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ func createSyncers(
314314
}))
315315
res.funcs = append(res.funcs, concurrent.WithSource(func(ctx context.Context) error {
316316
for _, syncer := range res.syncers {
317-
syncer.WaitComplete()
317+
if err := syncer.WaitComplete(ctx); err != nil {
318+
return err
319+
}
318320
}
319321
return res.syncers[0].SetHandlers(ctx)
320322
}))

0 commit comments

Comments
 (0)