avoid using the iterator variable

This commit is contained in:
c9s 2022-04-27 17:13:58 +08:00
parent 1f736d1f5e
commit 044470377b
No known key found for this signature in database
GPG Key ID: F0A7E4490F2EBC8C

View File

@ -504,14 +504,16 @@ func (environ *Environment) BindSync(config *SyncConfig) {
}
for _, session := range environ.sessions {
// avoid using the iterator variable.
s2 := session
// if trade sync is on, we will write all received trades
if config.UserDataStream.Trades {
tradeWriter := tradeWriterCreator(session)
tradeWriter := tradeWriterCreator(s2)
session.UserDataStream.OnTradeUpdate(tradeWriter)
}
if config.UserDataStream.FilledOrders {
orderWriter := orderWriterCreator(session)
orderWriter := orderWriterCreator(s2)
session.UserDataStream.OnOrderUpdate(orderWriter)
}
}