diff --git a/submodules/MtProtoKit/MTProtoKit/MTContext.h b/submodules/MtProtoKit/MTProtoKit/MTContext.h index 57c6474d9e..c4cff82ef3 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTContext.h +++ b/submodules/MtProtoKit/MTProtoKit/MTContext.h @@ -22,7 +22,7 @@ - (void)contextDatacenterAddressSetUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId addressSet:(MTDatacenterAddressSet *)addressSet; - (void)contextDatacenterAuthInfoUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId authInfo:(MTDatacenterAuthInfo *)authInfo; - (void)contextDatacenterAuthTokenUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId authToken:(id)authToken; -- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId; +- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId shouldReset:(bool)shouldReset; - (void)contextIsPasswordRequiredUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId; - (void)contextDatacenterPublicKeysUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId publicKeys:(NSArray *)publicKeys; - (MTSignal *)fetchContextDatacenterPublicKeys:(MTContext *)context datacenterId:(NSInteger)datacenterId; diff --git a/submodules/MtProtoKit/MTProtoKit/MTContext.m b/submodules/MtProtoKit/MTProtoKit/MTContext.m index 357148b856..e38d403363 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTContext.m +++ b/submodules/MtProtoKit/MTProtoKit/MTContext.m @@ -491,10 +491,11 @@ static int32_t fixedTimeDifferenceValue = 0; [listener contextDatacenterAddressSetUpdated:self datacenterId:datacenterId addressSet:addressSet]; } - if (previousAddressSetWasEmpty || updateSchemes || true) { + if (true) { + bool shouldReset = previousAddressSetWasEmpty || updateSchemes; for (id listener in currentListeners) { - if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:)]) { - [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId]; + if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:shouldReset:)]) { + [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId shouldReset:shouldReset]; } } } else { @@ -664,8 +665,8 @@ static int32_t fixedTimeDifferenceValue = 0; } for (id listener in currentListeners) { - if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:)]) - [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId]; + if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:shouldReset:)]) + [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId shouldReset:true]; } } }]; diff --git a/submodules/MtProtoKit/MTProtoKit/MTProto.m b/submodules/MtProtoKit/MTProtoKit/MTProto.m index bba17b43ca..a88d60767f 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTProto.m +++ b/submodules/MtProtoKit/MTProtoKit/MTProto.m @@ -2715,15 +2715,20 @@ static NSString *dumpHexString(NSData *data, int maxLength) { } } -- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId { +- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId shouldReset:(bool)shouldReset { [[MTProto managerQueue] dispatchOnQueue:^ { if (context == _context && datacenterId == _datacenterId && ![self isStopped]) { + bool resolvedShouldReset = shouldReset; + if (_mtState & MTProtoStateAwaitingDatacenterScheme) { [self setMtState:_mtState & (~MTProtoStateAwaitingDatacenterScheme)]; + resolvedShouldReset = true; } - [self resetTransport]; - [self requestTransportTransaction]; + if (resolvedShouldReset) { + [self resetTransport]; + [self requestTransportTransaction]; + } } }]; } diff --git a/submodules/TelegramCore/Sources/Network.swift b/submodules/TelegramCore/Sources/Network.swift index 3d74acad6e..24b84d3fff 100644 --- a/submodules/TelegramCore/Sources/Network.swift +++ b/submodules/TelegramCore/Sources/Network.swift @@ -514,7 +514,7 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary context.setDiscoverBackupAddressListSignal(MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber)) #if DEBUG - let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber).start(next: nil) + //let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber).start(next: nil) #endif let mtProto = MTProto(context: context, datacenterId: datacenterId, usageCalculationInfo: usageCalculationInfo(basePath: basePath, category: nil), requiredAuthToken: nil, authTokenMasterDatacenterId: 0)!