gotd/updates: initialize channel state runctx immediately

This commit is contained in:
Tulir Asokan
2025-12-11 14:37:01 +02:00
parent 042304f147
commit d03260c4a7
4 changed files with 23 additions and 24 deletions
+14 -18
View File
@@ -397,7 +397,20 @@ func (s *internalState) RemoveChannel(channelID int64, reason error) {
}
func (s *internalState) createAndRunChannelState(ctx context.Context, channelID, accessHash int64, initialPts int) (state *channelState) {
state = s.newChannelState(channelID, accessHash, initialPts)
state = newChannelState(ctx, channelStateConfig{
Out: s.internalQueue,
InitialPts: initialPts,
ChannelID: channelID,
AccessHash: accessHash,
SelfID: s.selfID,
Storage: s.storage,
DiffLimit: s.diffLim,
RawClient: s.client,
Handler: s.handler,
OnChannelTooLong: s.onTooLong,
Logger: s.log.Named("channel").With(zap.Int64("channel_id", channelID)),
Tracer: s.tracer,
})
s.channelsLock.Lock()
s.channels[channelID] = state
s.channelsLock.Unlock()
@@ -415,23 +428,6 @@ func (s *internalState) createAndRunChannelState(ctx context.Context, channelID,
return state
}
func (s *internalState) newChannelState(channelID, accessHash int64, initialPts int) *channelState {
return newChannelState(channelStateConfig{
Out: s.internalQueue,
InitialPts: initialPts,
ChannelID: channelID,
AccessHash: accessHash,
SelfID: s.selfID,
Storage: s.storage,
DiffLimit: s.diffLim,
RawClient: s.client,
Handler: s.handler,
OnChannelTooLong: s.onTooLong,
Logger: s.log.Named("channel").With(zap.Int64("channel_id", channelID)),
Tracer: s.tracer,
})
}
func (s *internalState) getDifference(ctx context.Context) error {
ctx, span := s.tracer.Start(ctx, "getDifference")
defer span.End()