Skip to content

Commit

Permalink
Merge pull request #511 from dashpay/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pankcuf authored Jul 21, 2023
2 parents 23dd88c + 993b677 commit af75b12
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ - (void)operationQueue:(DSOperationQueue *)operationQueue willAddOperation:(NSOp
}

- (void)operationQueue:(DSOperationQueue *)operationQueue operationDidFinish:(NSOperation *)operation withErrors:(NSArray<NSError *> *)errors {
[self.aggregatedErrors addObjectsFromArray:errors];
@synchronized(self.aggregatedErrors) {
[self.aggregatedErrors addObjectsFromArray:errors];
}

if (operation == self.finishingOperation) {
self.internalQueue.suspended = YES;
Expand Down
7 changes: 7 additions & 0 deletions DashSync/shared/Libraries/DSLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ - (instancetype)init {
[logFiles addObject:fileURL];
}
}
// add rust log file located at $CACHE/Logs/processor.log
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cacheDirectory = [paths objectAtIndex:0];
NSString *rustLogPath = [cacheDirectory stringByAppendingPathComponent:@"Logs/processor.log"];

if ([[NSFileManager defaultManager] fileExistsAtPath:rustLogPath]) {
[logFiles addObject:[NSURL fileURLWithPath:rustLogPath]];
}
return [logFiles copy];
}

Expand Down
28 changes: 13 additions & 15 deletions DashSync/shared/Models/Derivation Paths/DSFundsDerivationPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,22 @@ - (NSArray *)registerAddressesWithGapLimit:(NSUInteger)gapLimit internal:(BOOL)i
if (!self.account.wallet.isTransient) {
NSAssert(self.addressesLoaded, @"addresses must be loaded before calling this function");
}
@synchronized(self) {
NSMutableArray *a = [NSMutableArray arrayWithArray:(internal) ? self.internalAddresses : self.externalAddresses];
NSUInteger i = a.count;
// keep only the trailing contiguous block of addresses with no transactions
while (i > 0 && ![self.usedAddresses containsObject:a[i - 1]]) {
i--;
}

NSMutableArray *a = [NSMutableArray arrayWithArray:(internal) ? self.internalAddresses : self.externalAddresses];
NSUInteger i = a.count;

// keep only the trailing contiguous block of addresses with no transactions
while (i > 0 && ![self.usedAddresses containsObject:a[i - 1]]) {
i--;
}

if (i > 0) [a removeObjectsInRange:NSMakeRange(0, i)];
if (a.count >= gapLimit) return [a subarrayWithRange:NSMakeRange(0, gapLimit)];
if (i > 0) [a removeObjectsInRange:NSMakeRange(0, i)];
if (a.count >= gapLimit) return [a subarrayWithRange:NSMakeRange(0, gapLimit)];

if (gapLimit > 1) { // get receiveAddress and changeAddress first to avoid blocking
[self receiveAddress];
[self changeAddress];
}
if (gapLimit > 1) { // get receiveAddress and changeAddress first to avoid blocking
[self receiveAddress];
[self changeAddress];
}

@synchronized(self) {
//It seems weird to repeat this, but it's correct because of the original call receive address and change address
[a setArray:(internal) ? self.internalAddresses : self.externalAddresses];
i = a.count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ - (void)useMasternodeList:(DSMasternodeList *)masternodeList withConnectivityNon
// MARK: - Connectivity

- (void)connect {
DSLog(@"[DSPeerManager] connect (%d)", self.connectedPeers);
DSLog(@"[DSPeerManager] connect");
self.desiredState = DSPeerManagerDesiredState_Connected;
dispatch_async(self.networkingQueue, ^{
if ([self.chain syncsBlockchain] && ![self.chain canConstructAFilter]) return; // check to make sure the wallet has been created if only are a basic wallet with no dash features
Expand Down Expand Up @@ -770,7 +770,6 @@ - (void)connect {
}

if (peers.count == 0) {
DSLog(@"[DSPeerManager] connect failed peers: (%d) connected: (%d) mutableConnected: (%d)", peers, self.connectedPeers, self.mutableConnectedPeers);
[self chainSyncStopped];
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error = [NSError errorWithCode:1 localizedDescriptionKey:@"No peers found"];
Expand Down Expand Up @@ -995,8 +994,7 @@ - (void)peer:(DSPeer *)peer disconnectedWithError:(NSError *)error {
[self.managedObjectContext deleteObject:obj];
}
}];

DSLog(@"[DSPeerManager] disconnectedWithError: peers: (%d) connected: (%d) mutableConnected: (%d) connectFailures: (%d)", _peers, self.connectedPeers, self.mutableConnectedPeers, self.connectFailures);
DSLog(@"[DSPeerManager] disconnectedWithError: max connect failures exceeded");
@synchronized(self) {
_peers = nil;
}
Expand Down
6 changes: 2 additions & 4 deletions DashSync/shared/Models/Messages/DSPingRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#import "DSPingRequest.h"
#import "DSPeer.h"
#import "NSMutableData+Dash.h"
#import "NSData+Dash.h"

@implementation DSPingRequest

Expand All @@ -34,8 +34,6 @@ - (instancetype)initWithLocalNonce:(uint64_t)localNonce type:(NSString *)type {
}

- (NSData *)toData {
NSMutableData *msg = [NSMutableData data];
[msg appendUInt64:self.localNonce];
return msg;
return [NSData dataWithUInt64:self.localNonce];
}
@end

0 comments on commit af75b12

Please sign in to comment.