Merge branch 'mkirk/debug-spk'

pull/1/head
Michael Kirk 8 years ago
commit c47e766c10

@ -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

@ -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 <SignedPreKeyRecord: id: %d, generatedAt: %@, "
@"wasAcceptedByService:%@, signature: %@",
tag,
i,
signedPreKeyRecord.Id,
signedPreKeyRecord.generatedAt,
(signedPreKeyRecord.wasAcceptedByService ? @"YES" : @"NO"),
signedPreKeyRecord.signature);
}];
}];
}
@end
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save