Merge pull request #855 from dtynn/fix/duplicate_call_on_unsub

fix: duplicate unsub calls when client quits
This commit is contained in:
Łukasz Magiera 2019-12-11 14:09:09 +01:00 committed by GitHub
commit 62ede45dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,6 +155,8 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*HeadChange {
go func() {
defer close(out)
var unsubOnce sync.Once
for {
select {
case val, ok := <-subch:
@ -170,7 +172,9 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*HeadChange {
case <-ctx.Done():
}
case <-ctx.Done():
unsubOnce.Do(func() {
go cs.bestTips.Unsub(subch)
})
}
}
}()