Merge pull request #855 from dtynn/fix/duplicate_call_on_unsub
fix: duplicate unsub calls when client quits
This commit is contained in:
commit
62ede45dfc
@ -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():
|
||||
go cs.bestTips.Unsub(subch)
|
||||
unsubOnce.Do(func() {
|
||||
go cs.bestTips.Unsub(subch)
|
||||
})
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user