Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: migrations for Platform v0.22 to v1" #581

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DashSync.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Pod::Spec.new do |s|
s.dependency 'CocoaLumberjack', '3.7.2'
s.ios.dependency 'DWAlertController', '0.2.1'
s.dependency 'DSDynamicOptions', '0.1.2'
s.dependency 'DAPI-GRPC', '0.22.0-dev.8'
s.dependency 'TinyCborObjc', '0.4.6'
s.prefix_header_contents = '#import "DSEnvironment.h"'

Expand Down
8 changes: 4 additions & 4 deletions DashSync/shared/Models/DAPI/DSPlatformDocumentsRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ + (instancetype)dpnsRequestForUsername:(NSString *)username inDomain:(NSString *

+ (instancetype)dpnsRequestForUserId:(NSData *)userId {
DSPlatformDocumentsRequest *platformDocumentsRequest = [[DSPlatformDocumentsRequest alloc] init];
platformDocumentsRequest.pathPredicate = [NSPredicate predicateWithFormat:@"records.identity == %@", userId]; // why not path predicate and then predicate?
platformDocumentsRequest.pathPredicate = [NSPredicate predicateWithFormat:@"records.dashUniqueIdentityId == %@", userId];
platformDocumentsRequest.startAt = nil;
platformDocumentsRequest.limit = 100;
platformDocumentsRequest.queryType = DSPlatformQueryType_RangeOverIndex;
Expand Down Expand Up @@ -115,7 +115,7 @@ + (instancetype)dashpayRequestForContactRequestsForSendingUserId:(NSData *)userI
platformDocumentsRequest.startAtIncluded = false;
platformDocumentsRequest.limit = 100;
platformDocumentsRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"$createdAt" ascending:YES]];
platformDocumentsRequest.queryType = DSPlatformQueryType_RangeOverValue; // why not over index?
platformDocumentsRequest.queryType = DSPlatformQueryType_RangeOverValue;
platformDocumentsRequest.type = DSPlatformDocumentType_Document;
platformDocumentsRequest.tableName = @"contactRequest";
platformDocumentsRequest.prove = DSPROVE_PLATFORM_SINDEXES;
Expand All @@ -131,7 +131,7 @@ + (instancetype)dashpayRequestForContactRequestsForRecipientUserId:(NSData *)use
platformDocumentsRequest.startAtIncluded = false;
platformDocumentsRequest.limit = 100;
platformDocumentsRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"$createdAt" ascending:YES]];
platformDocumentsRequest.queryType = DSPlatformQueryType_RangeOverValue; // why not over index?
platformDocumentsRequest.queryType = DSPlatformQueryType_RangeOverValue;
platformDocumentsRequest.type = DSPlatformDocumentType_Document;
platformDocumentsRequest.tableName = @"contactRequest";
platformDocumentsRequest.prove = DSPROVE_PLATFORM_SINDEXES;
Expand All @@ -140,7 +140,7 @@ + (instancetype)dashpayRequestForContactRequestsForRecipientUserId:(NSData *)use

+ (instancetype)dashpayRequestForContactRequestForSendingUserId:(NSData *)userId toRecipientUserId:(NSData *)toUserId {
DSPlatformDocumentsRequest *platformDocumentsRequest = [[DSPlatformDocumentsRequest alloc] init];
platformDocumentsRequest.pathPredicate = [NSPredicate predicateWithFormat:@"%K == %@ && toUserId == %@", @"$ownerId", userId, toUserId]; // why not path predicate and predicate?
platformDocumentsRequest.pathPredicate = [NSPredicate predicateWithFormat:@"%K == %@ && toUserId == %@", @"$ownerId", userId, toUserId];
platformDocumentsRequest.startAt = nil;
platformDocumentsRequest.limit = 100;
platformDocumentsRequest.type = DSPlatformDocumentType_Document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,67 +450,46 @@ - (void)loadBloomFilter:(NSString *)filter

#pragma mark Layer 2

- (id<DSDAPINetworkServiceRequest>)fetchIdentityIdsByKeyHashes:(NSArray<NSData *> *)keyHashesArray
completionQueue:(dispatch_queue_t)completionQueue
success:(void (^)(NSArray<NSData *> *identityIds))success
failure:(void (^)(NSError *error))failure {
NSParameterAssert(keyHashesArray);
NSParameterAssert(completionQueue);
DSPlatformRequestLog(@"fetchIdentityIdsByKeyHashes %@", keyHashesArray);
GetIdentityIdsByPublicKeyHashesRequest *getIdentityIdsByPublicKeyHashesRequest = [[GetIdentityIdsByPublicKeyHashesRequest alloc] init];
getIdentityIdsByPublicKeyHashesRequest.publicKeyHashesArray = [keyHashesArray mutableCopy];
getIdentityIdsByPublicKeyHashesRequest.prove = DSPROVE_PLATFORM;
DSDAPIGRPCResponseHandler *responseHandler = [[DSDAPIGRPCResponseHandler alloc] initForGetIdentityIDsByPublicKeyHashesRequest:keyHashesArray withChain:self.chain requireProof:DSPROVE_PLATFORM];
responseHandler.host = [NSString stringWithFormat:@"%@:%d", self.ipAddress, self.chain.standardDapiGRPCPort];
responseHandler.dispatchQueue = self.grpcDispatchQueue;
responseHandler.completionQueue = completionQueue;
responseHandler.successHandler = success;
responseHandler.errorHandler = failure;
GRPCUnaryProtoCall *call = [self.gRPCClient getIdentityIdsByPublicKeyHashesWithMessage:getIdentityIdsByPublicKeyHashesRequest responseHandler:responseHandler callOptions:nil];
[call start];
return (id<DSDAPINetworkServiceRequest>)call;
}

- (id<DSDAPINetworkServiceRequest>)fetchIdentitiesByKeyHashes:(NSArray<NSData *> *)keyHashesArray
completionQueue:(dispatch_queue_t)completionQueue
success:(void (^)(NSArray<NSDictionary *> *identityDictionaries))success
failure:(void (^)(NSError *error))failure {
NSParameterAssert(keyHashesArray);
NSParameterAssert(completionQueue);
DSPlatformRequestLog(@"fetchIdentitiesByKeyHashes %@", keyHashesArray);

NSMutableArray<NSDictionary *> *identityDictionaries = [NSMutableArray array];
__block NSUInteger remainingRequests = keyHashesArray.count;
__block NSError *lastError = nil;

for (NSData *keyHash in keyHashesArray) {
GetIdentityByPublicKeyHashRequest *getIdentityByPublicKeyHashRequest = [[GetIdentityByPublicKeyHashRequest alloc] init];
getIdentityByPublicKeyHashRequest.publicKeyHash = keyHash;
getIdentityByPublicKeyHashRequest.prove = DSPROVE_PLATFORM;

DSDAPIGRPCResponseHandler *responseHandler = [[DSDAPIGRPCResponseHandler alloc] initForGetIdentitiesByPublicKeyHashesRequest:@[keyHash] withChain:self.chain requireProof:DSPROVE_PLATFORM];
responseHandler.host = [NSString stringWithFormat:@"%@:%d", self.ipAddress, self.chain.standardDapiGRPCPort];
responseHandler.dispatchQueue = self.grpcDispatchQueue;
responseHandler.completionQueue = completionQueue;

responseHandler.successHandler = ^(NSDictionary *responseDictionary) {
if (responseDictionary) {
@synchronized(identityDictionaries) {
[identityDictionaries addObject:responseDictionary];
}
}
@synchronized(self) {
remainingRequests--;
if (remainingRequests == 0) {
if (lastError) {
if (failure) {
failure(lastError);
}
} else {
if (success) {
success([identityDictionaries copy]);
}
}
}
}
};

responseHandler.errorHandler = ^(NSError *error) {
lastError = error;
@synchronized(self) {
remainingRequests--;
if (remainingRequests == 0) {
if (failure) {
failure(error);
}
}
}
};

GRPCUnaryProtoCall *call = [self.gRPCClient getIdentityByPublicKeyHashWithMessage:getIdentityByPublicKeyHashRequest responseHandler:responseHandler callOptions:nil];
[call start];
}

return nil;
GetIdentitiesByPublicKeyHashesRequest *getIdentitiesByPublicKeyHashesRequest = [[GetIdentitiesByPublicKeyHashesRequest alloc] init];
getIdentitiesByPublicKeyHashesRequest.publicKeyHashesArray = [keyHashesArray mutableCopy];
getIdentitiesByPublicKeyHashesRequest.prove = DSPROVE_PLATFORM;
DSDAPIGRPCResponseHandler *responseHandler = [[DSDAPIGRPCResponseHandler alloc] initForGetIdentitiesByPublicKeyHashesRequest:keyHashesArray withChain:self.chain requireProof:DSPROVE_PLATFORM];
responseHandler.host = [NSString stringWithFormat:@"%@:%d", self.ipAddress, self.chain.standardDapiGRPCPort];
responseHandler.dispatchQueue = self.grpcDispatchQueue;
responseHandler.completionQueue = completionQueue;
responseHandler.successHandler = success;
responseHandler.errorHandler = failure;
GRPCUnaryProtoCall *call = [self.gRPCClient getIdentitiesByPublicKeyHashesWithMessage:getIdentitiesByPublicKeyHashesRequest responseHandler:responseHandler callOptions:nil];
[call start];
return (id<DSDAPINetworkServiceRequest>)call;
}

- (id<DSDAPINetworkServiceRequest>)fetchContractForId:(NSData *)contractId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,21 +487,31 @@ Get a list of users after matching search criteria
failure:(void (^)(NSError *error))failure;

/**
Get a list of identities corresponding to the provided key hashes.
Get a list of identities knowing only keys they possess

This method makes individual requests for each key hash in the array and returns a list of identity dictionaries upon successful completion. If any request fails, the failure block is called.

@param keyHashesArray An array of hashes of keys for which to fetch identities.
@param completionQueue The queue on which to execute the success or failure block.
@param success A block object to be executed when all requests finish successfully, providing an array of identity dictionaries.
@param failure A block object to be executed if any request fails, providing the error encountered.
@return Returns an object conforming to `DSDAPINetworkServiceRequest`, or `nil` if no request is made.
@param keyHashesArray An array of hashes of keys
@param completionQueue The queue in which to return the result on
@param success A block object to be executed when the request operation finishes successfully
@param failure A block object to be executed when the request operation finishes unsuccessfully
*/
- (id<DSDAPINetworkServiceRequest>)fetchIdentitiesByKeyHashes:(NSArray<NSData *> *)keyHashesArray
completionQueue:(dispatch_queue_t)completionQueue
success:(void (^)(NSArray<NSDictionary *> *identityDictionaries))success
failure:(void (^)(NSError *error))failure;

/**
Get a list of identity Ids knowing only keys they possess

@param keyHashesArray An array of hashes of keys
@param completionQueue The queue in which to return the result on
@param success A block object to be executed when the request operation finishes successfully
@param failure A block object to be executed when the request operation finishes unsuccessfully
*/
- (id<DSDAPINetworkServiceRequest>)fetchIdentityIdsByKeyHashes:(NSArray<NSData *> *)keyHashesArray
completionQueue:(dispatch_queue_t)completionQueue
success:(void (^)(NSArray<NSData *> *identityIds))success
failure:(void (^)(NSError *error))failure;

@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion DashSync/shared/Models/Identity/DSBlockchainIdentity.m
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ - (NSString *)dashpayDomainName {
@"normalizedLabel": [username lowercaseString],
@"normalizedParentDomainName": domain,
@"preorderSalt": [self.usernameSalts objectForKey:usernameFullPath],
@"records": @{@"identity": uint256_data(self.uniqueID)},
@"records": @{@"dashUniqueIdentityId": uint256_data(self.uniqueID)},
@"subdomainRules": @{@"allowSubdomains": @NO}
};
DPDocument *document = [self.dpnsDocumentFactory documentOnTable:@"domain" withDataDictionary:dataDictionary usingEntropy:entropyData error:error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ - (instancetype)initWithChain:(DSChain *)chain {

#pragma mark - DSMasternodeListServiceDelegate

- (DSMasternodeList *__nullable)masternodeListServiceDidRequestFileFromBlockHash:(DSMasternodeListService *)service blockHash:(UInt256)blockHash {
- (DSMasternodeList *__nullable)masternodeListSerivceDidRequestFileFromBlockHash:(DSMasternodeListService *)service blockHash:(UInt256)blockHash {
return [self processRequestFromFileForBlockHash:blockHash];
}

- (void)masternodeListServiceExceededMaxFailuresForMasternodeList:(DSMasternodeListService *)service blockHash:(UInt256)blockHash {
- (void)masternodeListSerivceExceededMaxFailuresForMasternodeList:(DSMasternodeListService *)service blockHash:(UInt256)blockHash {
[self removeOutdatedMasternodeListsBeforeBlockHash:blockHash];
}

- (void)masternodeListServiceEmptiedRetrievalQueue:(DSMasternodeListService *)service {
- (void)masternodeListSerivceEmptiedRetrievalQueue:(DSMasternodeListService *)service {
if (![self.masternodeListDiffService retrievalQueueCount]) {
if (![self.quorumRotationService retrievalQueueCount])
[self removeOutdatedMasternodeListsBeforeBlockHash:self.store.lastQueriedBlockHash];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (void)composeMasternodeListRequest:(NSOrderedSet<NSData *> *)list {
//there is the rare possibility we have the masternode list as a checkpoint, so lets first try that
NSUInteger pos = [list indexOfObject:blockHashData];
UInt256 blockHash = blockHashData.UInt256;
DSMasternodeList *masternodeList = [self.delegate masternodeListServiceDidRequestFileFromBlockHash:self blockHash:blockHash];
DSMasternodeList *masternodeList = [self.delegate masternodeListSerivceDidRequestFileFromBlockHash:self blockHash:blockHash];
if (masternodeList) {
[self removeFromRetrievalQueue:blockHashData];
[self checkWaitingForQuorums];
Expand Down
6 changes: 3 additions & 3 deletions DashSync/shared/Models/Masternode/DSMasternodeListService.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ typedef NS_ENUM(NSUInteger, DSMasternodeListRequestMode) {

@protocol DSMasternodeListServiceDelegate <NSObject>

- (DSMasternodeList *__nullable)masternodeListServiceDidRequestFileFromBlockHash:(DSMasternodeListService *)service blockHash:(UInt256)blockHash;
- (void)masternodeListServiceExceededMaxFailuresForMasternodeList:(DSMasternodeListService *)service blockHash:(UInt256)blockHash;
- (void)masternodeListServiceEmptiedRetrievalQueue:(DSMasternodeListService *)service;
- (DSMasternodeList *__nullable)masternodeListSerivceDidRequestFileFromBlockHash:(DSMasternodeListService *)service blockHash:(UInt256)blockHash;
- (void)masternodeListSerivceExceededMaxFailuresForMasternodeList:(DSMasternodeListService *)service blockHash:(UInt256)blockHash;
- (void)masternodeListSerivceEmptiedRetrievalQueue:(DSMasternodeListService *)service;

@end

Expand Down
4 changes: 2 additions & 2 deletions DashSync/shared/Models/Masternode/DSMasternodeListService.m
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ - (void)updateMasternodeRetrievalQueue {
- (void)fetchMasternodeListsToRetrieve:(void (^)(NSOrderedSet<NSData *> *listsToRetrieve))completion {
if (![self retrievalQueueCount]) {
DSLog(@"[%@] No masternode lists in retrieval: %@", self.chain.name, self);
[self.delegate masternodeListServiceEmptiedRetrievalQueue:self];
[self.delegate masternodeListSerivceEmptiedRetrievalQueue:self];
return;
}
if ([self.requestsInRetrieval count]) {
Expand Down Expand Up @@ -385,7 +385,7 @@ - (void)issueWithMasternodeListFromPeer:(DSPeer *)peer {
//no need to remove local masternodes
[self cleanListsRetrievalQueue];
[self.store deleteAllOnChain];
[self.delegate masternodeListServiceExceededMaxFailuresForMasternodeList:self blockHash:self.currentMasternodeList.blockHash];
[self.delegate masternodeListSerivceExceededMaxFailuresForMasternodeList:self blockHash:self.currentMasternodeList.blockHash];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:CHAIN_FAULTY_DML_MASTERNODE_PEERS];
[self getRecentMasternodeList];
} else {
Expand Down
Loading
Loading