Skip to content

Commit

Permalink
fix: db masternode entry merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pankcuf committed Jan 17, 2024
1 parent 71d2f95 commit def9c76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ - (void)updateAttributesFromSimplifiedMasternodeEntry:(DSSimplifiedMasternodeEnt
self.operatorPublicKeyVersion = simplifiedMasternodeEntry.operatorPublicKeyVersion;
DSDSMNELog(@"changing operatorBLSPublicKey to %@", operatorPublicKeyData.hexString);
}

if (self.type != simplifiedMasternodeEntry.type) {
self.type = simplifiedMasternodeEntry.type;
DSDSMNELog(@"changing type to %d", simplifiedMasternodeEntry.type);
}
NSData *platformNodeIDData = uint160_data(simplifiedMasternodeEntry.platformNodeID);
if (![self.platformNodeID isEqualToData:platformNodeIDData]) {
self.platformNodeID = platformNodeIDData;
DSDSMNELog(@"changing platformNodeID to %d", platformNodeIDData.hexString);
}
if (self.platformHTTPPort != simplifiedMasternodeEntry.platformHTTPPort) {
self.platformHTTPPort = simplifiedMasternodeEntry.platformHTTPPort;
DSDSMNELog(@"changing platformHTTPPort to %d", simplifiedMasternodeEntry.platformHTTPPort);
}

if (self.isValid != simplifiedMasternodeEntry.isValid) {
self.isValid = simplifiedMasternodeEntry.isValid;
DSDSMNELog(@"changing isValid to %@", simplifiedMasternodeEntry.isValid ? @"TRUE" : @"FALSE");
Expand Down Expand Up @@ -149,6 +164,9 @@ - (void)setAttributesFromSimplifiedMasternodeEntry:(DSSimplifiedMasternodeEntry
self.keyIDVoting = [NSData dataWithUInt160:simplifiedMasternodeEntry.keyIDVoting];
self.operatorBLSPublicKey = [NSData dataWithUInt384:simplifiedMasternodeEntry.operatorPublicKey];
self.operatorPublicKeyVersion = simplifiedMasternodeEntry.operatorPublicKeyVersion;
self.type = simplifiedMasternodeEntry.type;
self.platformNodeID = [NSData dataWithUInt160:simplifiedMasternodeEntry.platformNodeID];
self.platformHTTPPort = simplifiedMasternodeEntry.platformHTTPPort;
self.isValid = simplifiedMasternodeEntry.isValid;
self.simplifiedMasternodeEntryHash = [NSData dataWithUInt256:simplifiedMasternodeEntry.simplifiedMasternodeEntryHash];
self.updateHeight = blockHeight;
Expand All @@ -169,6 +187,7 @@ - (void)setAttributesFromSimplifiedMasternodeEntry:(DSSimplifiedMasternodeEntry
self.localMasternode = localMasternode;
NSString *operatorAddress = [DSKeyManager addressWithPublicKeyData:self.operatorBLSPublicKey forChain:simplifiedMasternodeEntry.chain];
NSString *votingAddress = [DSKeyManager addressFromHash160:self.keyIDVoting.UInt160 forChain:simplifiedMasternodeEntry.chain];
// TODO: check do we have to do the same for platform node addresses
DSAddressEntity *operatorAddressEntity = knownOperatorAddresses
? [knownOperatorAddresses objectForKey:operatorAddress]
: [DSAddressEntity findAddressMatching:operatorAddress onChain:simplifiedMasternodeEntry.chain inContext:self.managedObjectContext];
Expand Down
1 change: 1 addition & 0 deletions DashSync/shared/Models/Masternode/DSMasternodeListStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ + (void)saveMasternodeList:(DSMasternodeList *)masternodeList
NSMutableSet<NSString *> *operatorAddressStrings = [NSMutableSet set];
NSMutableSet<NSData *> *providerRegistrationTransactionHashes = [NSMutableSet set];
NSArray<DSSimplifiedMasternodeEntry *> *masternodes = masternodeList.simplifiedMasternodeEntries;
// TODO: check do we have to do the same for platform node addresses
for (DSSimplifiedMasternodeEntry *simplifiedMasternodeEntry in masternodes) {
[votingAddressStrings addObject:simplifiedMasternodeEntry.votingAddress];
[operatorAddressStrings addObject:simplifiedMasternodeEntry.operatorAddress];
Expand Down

0 comments on commit def9c76

Please sign in to comment.