diff --git a/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.h b/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.h index 0297f23a4..27b4d802f 100644 --- a/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.h +++ b/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.h @@ -30,6 +30,10 @@ extern NSString *const TSStorageManagerSignedPreKeyStoreCollection; - (void)setFirstPrekeyUpdateFailureDate:(nonnull NSDate *)value; - (void)clearFirstPrekeyUpdateFailureDate; +#pragma mark - Debugging + +- (void)logSignedPreKeyReport; + @end NS_ASSUME_NONNULL_END diff --git a/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m b/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m index 9684d06c1..ed9ffc848 100644 --- a/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m +++ b/src/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m @@ -137,6 +137,53 @@ NSString *const TSStorageManagerKeyPrekeyCurrentSignedPrekeyId = @"currentSigned inCollection:TSStorageManagerSignedPreKeyMetadataCollection]; } +#pragma mark - Debugging + +- (void)logSignedPreKeyReport +{ + NSString *tag = @"[TSStorageManager (SignedPreKeyStore)]"; + + NSNumber *currentId = [self currentSignedPrekeyId]; + NSDate *firstPrekeyUpdateFailureDate = [self firstPrekeyUpdateFailureDate]; + NSUInteger prekeyUpdateFailureCount = [self prekeyUpdateFailureCount]; + + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) { + __block int i = 0; + + DDLogInfo(@"%@ SignedPreKeys Report:", tag); + DDLogInfo(@"%@ currentId: %@", tag, currentId); + DDLogInfo(@"%@ firstPrekeyUpdateFailureDate: %@", tag, firstPrekeyUpdateFailureDate); + DDLogInfo(@"%@ prekeyUpdateFailureCount: %d", tag, prekeyUpdateFailureCount); + + NSUInteger count = [transaction numberOfKeysInCollection:TSStorageManagerSignedPreKeyStoreCollection]; + DDLogInfo(@"%@ All Keys (count: %lu):", tag, (unsigned long)count); + + [transaction + enumerateKeysAndObjectsInCollection:TSStorageManagerSignedPreKeyStoreCollection + usingBlock:^( + NSString *_Nonnull key, id _Nonnull signedPreKeyObject, BOOL *_Nonnull stop) { + i++; + if (![signedPreKeyObject isKindOfClass:[SignedPreKeyRecord class]]) { + DDLogError(@"%@ Was expecting SignedPreKeyRecord, but found: %@", + tag, + signedPreKeyObject); + OWSAssert(NO); + return; + } + SignedPreKeyRecord *signedPreKeyRecord + = (SignedPreKeyRecord *)signedPreKeyObject; + DDLogInfo(@"%@ #%d