Skip to content
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
2 changes: 1 addition & 1 deletion DashWallet/DWAmountViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ - (void)viewWillAppear:(BOOL)animated
self.balanceObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil
usingBlock:^(NSNotification *note) {
if ([DWEnvironment sharedInstance].currentChainPeerManager.syncProgress < 1.0) return; // wait for sync before updating balance
if ([DWEnvironment sharedInstance].currentChainManager.syncProgress < 1.0) return; // wait for sync before updating balance
if ([[DSAuthenticationManager sharedInstance] didAuthenticate]) {
[self updateTitleView];
}
Expand Down
14 changes: 7 additions & 7 deletions DashWallet/DWAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ - (void)application:(UIApplication *)application
protectedObserver = syncFinishedObserver = syncFailedObserver = nil;
};

if ([DWEnvironment sharedInstance].currentChainPeerManager.syncProgress >= 1.0) {
if ([DWEnvironment sharedInstance].currentChainManager.syncProgress >= 1.0) {
NSLog(@"background fetch already synced");
if (completion) completion(UIBackgroundFetchResultNoData);
return;
Expand All @@ -169,8 +169,8 @@ - (void)application:(UIApplication *)application
// timeout after 25 seconds
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 25*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
if (completion) {
NSLog(@"background fetch timeout with progress: %f", [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress);
completion(([DWEnvironment sharedInstance].currentChainPeerManager.syncProgress > 0.1) ? UIBackgroundFetchResultNewData :
NSLog(@"background fetch timeout with progress: %f", [DWEnvironment sharedInstance].currentChainManager.syncProgress);
completion(([DWEnvironment sharedInstance].currentChainManager.syncProgress > 0.1) ? UIBackgroundFetchResultNewData :
UIBackgroundFetchResultFailed);
cleanup();
}
Expand All @@ -181,27 +181,27 @@ - (void)application:(UIApplication *)application
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationProtectedDataDidBecomeAvailable object:nil
queue:nil usingBlock:^(NSNotification *note) {
NSLog(@"background fetch protected data available");
[[DWEnvironment sharedInstance].currentChainPeerManager connect];
[[DWEnvironment sharedInstance].currentChainManager.peerManager connect];
}];

syncFinishedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification object:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncFinishedNotification object:nil
queue:nil usingBlock:^(NSNotification *note) {
NSLog(@"background fetch sync finished");
if (completion) completion(UIBackgroundFetchResultNewData);
cleanup();
}];

syncFailedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncFailedNotification object:nil
queue:nil usingBlock:^(NSNotification *note) {
NSLog(@"background fetch sync failed");
if (completion) completion(UIBackgroundFetchResultFailed);
cleanup();
}];

NSLog(@"background fetch starting");
[[DWEnvironment sharedInstance].currentChainPeerManager connect];
[[DWEnvironment sharedInstance].currentChainManager.peerManager connect];

// sync events to the server
[[DSEventManager sharedEventManager] sync];
Expand Down
2 changes: 1 addition & 1 deletion DashWallet/DWEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,strong,nonnull) DSChain * currentChain;
@property (nonatomic,readonly) DSWallet * currentWallet;
@property (nonatomic,readonly) DSAccount * currentAccount;
@property (nonatomic,strong) DSChainPeerManager * currentChainPeerManager;
@property (nonatomic,strong) DSChainManager * currentChainManager;

+ (instancetype _Nullable)sharedInstance;
- (void)clearWallet;
Expand Down
4 changes: 2 additions & 2 deletions DashWallet/DWEnvironment.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ -(void)reset {
default:
break;
}
self.currentChainPeerManager = [[DSChainManager sharedInstance] peerManagerForChain:self.currentChain];
self.currentChainManager = [[DSChainsManager sharedInstance] chainManagerForChain:self.currentChain];
}

-(DSWallet*)currentWallet {
Expand Down Expand Up @@ -94,7 +94,7 @@ - (void)switchToNetwork:(DSChainType)chainType {

}];
}
[self.currentChainPeerManager connect];
[self.currentChainManager.peerManager connect];
}

@end
6 changes: 3 additions & 3 deletions DashWallet/DWPhoneWCSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ - (instancetype)init
self.balanceObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil
queue:nil usingBlock:^(NSNotification * _Nonnull note) {
if ([DWEnvironment sharedInstance].currentChainPeerManager.syncProgress == 1.0) [self sendApplicationContext];
if ([DWEnvironment sharedInstance].currentChainManager.syncProgress == 1.0) [self sendApplicationContext];
}];

self.syncFinishedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncFinishedNotification
object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self sendApplicationContext];
}];

self.syncFailedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncFailedNotification object:nil
queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self sendApplicationContext];
}];
Expand Down
19 changes: 15 additions & 4 deletions DashWallet/DWReceiveViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ @interface DWReceiveViewController ()
@property (nonatomic, strong) BRBubbleView *tipView;
@property (nonatomic, assign) BOOL showTips;
@property (nonatomic, strong) NSUserDefaults *groupDefs;
@property (nonatomic, strong) id balanceObserver, txStatusObserver;
@property (nonatomic, strong) id balanceObserver, txStatusObserver, txReceivedObserver;

@property (nonatomic, strong) IBOutlet UILabel *label;
@property (nonatomic, strong) IBOutlet UIButton *addressButton;
Expand Down Expand Up @@ -100,6 +100,7 @@ - (void)viewWillDisappear:(BOOL)animated

- (void)dealloc
{
if (self.txReceivedObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.txReceivedObserver];
if (self.balanceObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.balanceObserver];
if (self.txStatusObserver) [[NSNotificationCenter defaultCenter] removeObserver:self.txStatusObserver];
}
Expand Down Expand Up @@ -170,11 +171,21 @@ - (void)updateAddress

if (! self.txStatusObserver) {
self.txStatusObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerTransactionStatusDidChangeNotification
object:nil queue:nil usingBlock:^(NSNotification *note) {
[self checkRequestStatus];
}];
}

if (! self.txReceivedObserver) {
self.txReceivedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerTransactionReceivedNotification
object:nil queue:nil usingBlock:^(NSNotification *note) {
[self updateAddress];
}];
}


}
});
});
Expand All @@ -184,7 +195,7 @@ - (void)checkRequestStatus
{
DSPriceManager * priceManager = [DSPriceManager sharedInstance];
DSWallet * wallet = [DWEnvironment sharedInstance].currentWallet;
DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager;
DSChainManager * chainManager = [DWEnvironment sharedInstance].currentChainManager;
DSPaymentRequest *req = self.paymentRequest;
uint64_t total = 0, fuzz = [priceManager amountForLocalCurrencyString:[priceManager localCurrencyStringForDashAmount:1]]*2;

Expand All @@ -193,7 +204,7 @@ - (void)checkRequestStatus
for (DSTransaction *tx in wallet.allTransactions) {
if ([tx.outputAddresses containsObject:self.paymentAddress]) continue;
if (tx.blockHeight == TX_UNCONFIRMED &&
[chainPeerManager relayCountForTransaction:tx.txHash] < PEER_MAX_CONNECTIONS) continue;
[chainManager.transactionManager relayCountForTransaction:tx.txHash] < PEER_MAX_CONNECTIONS) continue;
total += [wallet amountReceivedFromTransaction:tx];

if (total + fuzz >= req.amount) {
Expand Down
34 changes: 17 additions & 17 deletions DashWallet/DWRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {
queue:nil usingBlock:^(NSNotification *note) {
if ([DWEnvironment sharedInstance].currentChain.hasAWallet) {
DSEventManager *eventMan = [DSEventManager sharedEventManager];
DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager;
DSChainManager * chainManager = [DWEnvironment sharedInstance].currentChainManager;

[chainPeerManager connect];
[chainManager.peerManager connect];
[self.sendViewController updateClipboardText];

if (eventMan.isInSampleGroup && ! eventMan.hasAskedForPermission) {
Expand Down Expand Up @@ -406,7 +406,7 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {

if ([DWEnvironment sharedInstance].currentChain.hasAWallet && self.reachability.currentReachabilityStatus != NotReachable &&
[UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
[[DWEnvironment sharedInstance].currentChainPeerManager connect];
[[DWEnvironment sharedInstance].currentChainManager.peerManager connect];
}
else if ([DWEnvironment sharedInstance].currentChain.hasAWallet && self.reachability.currentReachabilityStatus == NotReachable) {
[self showErrorBar];
Expand All @@ -416,7 +416,7 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {
self.balanceObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil
usingBlock:^(NSNotification *note) {
double progress = [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress;
double progress = [DWEnvironment sharedInstance].currentChainManager.syncProgress;

if (self->_balance != UINT64_MAX && progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0) { // wait for sync
self.balance = self->_balance; // this updates the local currency value with the latest exchange rate
Expand All @@ -436,15 +436,15 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {
}];

self.syncStartedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncStartedNotification object:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncStartedNotification object:nil
queue:nil usingBlock:^(NSNotification *note) {
if (self.reachability.currentReachabilityStatus == NotReachable) return;
[self hideErrorBarWithCompletion:nil];
[self startActivityWithTimeout:0];
}];

self.syncFinishedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFinishedNotification object:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncFinishedNotification object:nil
queue:nil usingBlock:^(NSNotification *note) {
if (self.timeout < 1.0) [self stopActivityWithSuccess:YES];
[self showBackupDialogIfNeeded];
Expand All @@ -456,7 +456,7 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {
}];

self.syncFailedObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncFailedNotification object:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncFailedNotification object:nil
queue:nil usingBlock:^(NSNotification *note) {
if (self.timeout < 1.0) [self stopActivityWithSuccess:YES];
[self showBackupDialogIfNeeded];
Expand All @@ -465,8 +465,8 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {
}];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(chainPeerManagerNewBlockNotification)
name:DSChainPeerManagerNewBlockNotification
selector:@selector(chainNewBlockNotification)
name:DSChainNewBlockNotification
object:nil];
}

Expand Down Expand Up @@ -639,7 +639,7 @@ - (void)protectedViewDidAppear
}

if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
[[DWEnvironment sharedInstance].currentChainPeerManager connect];
[[DWEnvironment sharedInstance].currentChainManager.peerManager connect];
[UIApplication sharedApplication].applicationIconBadgeNumber = 0; // reset app badge number

if (self.url) {
Expand Down Expand Up @@ -805,7 +805,7 @@ -(void)updateTitleView {

- (void)showSyncing
{
double progress = [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress;
double progress = [DWEnvironment sharedInstance].currentChainManager.syncProgress;
DSWallet * wallet = [DWEnvironment sharedInstance].currentWallet;
if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0 && wallet.walletCreationTime + DAY_TIME_INTERVAL < [NSDate timeIntervalSince1970]) {
self.shouldShowTips = NO;
Expand Down Expand Up @@ -846,7 +846,7 @@ - (void)startActivityWithTimeout:(NSTimeInterval)timeout

- (void)stopActivityWithSuccess:(BOOL)success
{
double progress = [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress;
double progress = [DWEnvironment sharedInstance].currentChainManager.syncProgress;

self.start = self.timeout = 0.0;
if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0) return; // not done syncing
Expand Down Expand Up @@ -877,9 +877,9 @@ - (void)setProgressTo:(NSNumber *)n
self.progress.progress = n.floatValue;
}

- (void)chainPeerManagerNewBlockNotification
- (void)chainNewBlockNotification
{
double progress = [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress;
double progress = [DWEnvironment sharedInstance].currentChainManager.syncProgress;
if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0) { // not done syncing
if (self.progress.hidden) {
[self startActivityWithTimeout:0];
Expand All @@ -899,7 +899,7 @@ - (void)updateProgress

static int counter = 0;
NSTimeInterval elapsed = [NSDate timeIntervalSince1970] - self.start;
double progress = [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress;
double progress = [DWEnvironment sharedInstance].currentChainManager.syncProgress;
DSChain * chain = [DWEnvironment sharedInstance].currentChain;
if (progress > DBL_EPSILON && ! self.shouldShowTips && self.tipView.alpha > 0.5) {
self.tipView.text = [NSString stringWithFormat:NSLocalizedString(@"block #%d of %d", nil),
Expand Down Expand Up @@ -1140,7 +1140,7 @@ - (IBAction)connect:(id)sender
{
[DSEventManager saveEvent:@"root:connect"];
if (! sender && [self.reachability currentReachabilityStatus] == NotReachable) return;
[[DWEnvironment sharedInstance].currentChainPeerManager connect];
[[DWEnvironment sharedInstance].currentChainManager.peerManager connect];
[DSEventManager saveEvent:@"root:connect_success"];
if (self.reachability.currentReachabilityStatus == NotReachable) [self showErrorBar];
}
Expand Down Expand Up @@ -1363,7 +1363,7 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionCo
}
else if ([from isKindOfClass:[UINavigationController class]] && to == self.navigationController) { // modal dismiss
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
[[DWEnvironment sharedInstance].currentChainPeerManager connect];
[[DWEnvironment sharedInstance].currentChainManager.peerManager connect];
[self.sendViewController updateClipboardText];
}

Expand Down
2 changes: 1 addition & 1 deletion DashWallet/DWScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ - (void)viewWillAppear:(BOOL)animated
self.preview.frame = self.view.layer.bounds;
[self.cameraView.layer addSublayer:self.preview];

dispatch_async(dispatch_queue_create("qrscanner", NULL), ^{
dispatch_async(dispatch_queue_create("org.dashcore.dashwallet.qrscanner", NULL), ^{
[self.session startRunning];
});
}
Expand Down
Loading