Skip to content

Commit

Permalink
fix: sync pong handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
pankcuf committed Jul 11, 2024
1 parent 5e49827 commit 3a6b246
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,6 @@ - (void)connect {
dispatch_async(self.networkingQueue, ^{ [self.chain saveBlockLocators]; });
[self chainSyncStopped];
}];
[self.backgroundManager createBlockLocatorsTask:^{
dispatch_async(self.networkingQueue, ^{ [self.chain saveBlockLocators]; });
[self chainSyncStopped];
}];
}

if (self.chainManager.syncState.chainSyncProgress < 1.0) {
Expand Down
15 changes: 10 additions & 5 deletions DashSync/shared/Models/Network/DSPeer.m
Original file line number Diff line number Diff line change
Expand Up @@ -1638,11 +1638,16 @@ - (void)acceptPongMessage:(NSData *)message {
DSLogWithLocation(self, @"got pong in %fs", self.pingTime);
#endif
if (self->_status == DSPeerStatus_Connected && self.pongHandlers.count) {
void (^handler)(BOOL) = [self.pongHandlers objectAtIndex:0];
[self.pongHandlers removeObjectAtIndex:0];
[self dispatchAsyncInDelegateQueue:^{
handler(YES);
}];
void (^handler)(BOOL) = nil;
@synchronized(self.pongHandlers) {
if (self.pongHandlers.count > 0) {
handler = [self.pongHandlers objectAtIndex:0];
[self.pongHandlers removeObjectAtIndex:0];
}
}
if (handler) {
[self dispatchAsyncInDelegateQueue:^{ handler(YES); }];
}
}
}

Expand Down

0 comments on commit 3a6b246

Please sign in to comment.