mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 01:01:56 +00:00
xdepthmaker: refactor auth binding to bindAuthSignal
This commit is contained in:
parent
2c3ccdf030
commit
de7eb8453b
|
@ -367,18 +367,8 @@ func (s *Strategy) CrossRun(
|
|||
}
|
||||
|
||||
s.authedC = make(chan struct{}, 2)
|
||||
s.makerSession.UserDataStream.OnAuth(func() {
|
||||
select {
|
||||
case s.authedC <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
})
|
||||
s.hedgeSession.UserDataStream.OnAuth(func() {
|
||||
select {
|
||||
case s.authedC <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
})
|
||||
bindAuthSignal(ctx, s.makerSession.UserDataStream, s.authedC)
|
||||
bindAuthSignal(ctx, s.hedgeSession.UserDataStream, s.authedC)
|
||||
|
||||
go func() {
|
||||
log.Infof("waiting for user data stream to get authenticated")
|
||||
|
@ -936,3 +926,14 @@ func min(a, b int) int {
|
|||
|
||||
return b
|
||||
}
|
||||
|
||||
func bindAuthSignal(ctx context.Context, stream types.Stream, c chan<- struct{}) {
|
||||
stream.OnAuth(func() {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case c <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user