From a232db92a15d05f1238277ad72d5b03927764ddc Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 26 Nov 2018 12:32:48 +0700 Subject: [PATCH] changes for rearchitecture --- DashWallet/DWAmountViewController.m | 2 +- DashWallet/DWAppDelegate.m | 14 +++++------ DashWallet/DWEnvironment.h | 2 +- DashWallet/DWEnvironment.m | 4 +-- DashWallet/DWPhoneWCSessionManager.m | 6 ++--- DashWallet/DWReceiveViewController.m | 19 +++++++++++--- DashWallet/DWRootViewController.m | 34 +++++++++++++------------- DashWallet/DWScanViewController.m | 2 +- DashWallet/DWSeedViewController.m | 2 +- DashWallet/DWSendViewController.m | 14 +++++------ DashWallet/DWSettingsViewController.m | 20 +++++++-------- DashWallet/DWTxDetailViewController.m | 8 +++--- DashWallet/DWTxHistoryViewController.m | 2 +- 13 files changed, 70 insertions(+), 59 deletions(-) diff --git a/DashWallet/DWAmountViewController.m b/DashWallet/DWAmountViewController.m index b3907a8f5..420b910f8 100644 --- a/DashWallet/DWAmountViewController.m +++ b/DashWallet/DWAmountViewController.m @@ -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]; } diff --git a/DashWallet/DWAppDelegate.m b/DashWallet/DWAppDelegate.m index dd6adc691..7ad02238c 100644 --- a/DashWallet/DWAppDelegate.m +++ b/DashWallet/DWAppDelegate.m @@ -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; @@ -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(); } @@ -181,11 +181,11 @@ - (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); @@ -193,7 +193,7 @@ - (void)application:(UIApplication *)application }]; 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); @@ -201,7 +201,7 @@ - (void)application:(UIApplication *)application }]; NSLog(@"background fetch starting"); - [[DWEnvironment sharedInstance].currentChainPeerManager connect]; + [[DWEnvironment sharedInstance].currentChainManager.peerManager connect]; // sync events to the server [[DSEventManager sharedEventManager] sync]; diff --git a/DashWallet/DWEnvironment.h b/DashWallet/DWEnvironment.h index 9b1a8b6a6..d8484ff04 100644 --- a/DashWallet/DWEnvironment.h +++ b/DashWallet/DWEnvironment.h @@ -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; diff --git a/DashWallet/DWEnvironment.m b/DashWallet/DWEnvironment.m index de1a97e80..32d82fe20 100644 --- a/DashWallet/DWEnvironment.m +++ b/DashWallet/DWEnvironment.m @@ -49,7 +49,7 @@ -(void)reset { default: break; } - self.currentChainPeerManager = [[DSChainManager sharedInstance] peerManagerForChain:self.currentChain]; + self.currentChainManager = [[DSChainsManager sharedInstance] chainManagerForChain:self.currentChain]; } -(DSWallet*)currentWallet { @@ -94,7 +94,7 @@ - (void)switchToNetwork:(DSChainType)chainType { }]; } - [self.currentChainPeerManager connect]; + [self.currentChainManager.peerManager connect]; } @end diff --git a/DashWallet/DWPhoneWCSessionManager.m b/DashWallet/DWPhoneWCSessionManager.m index eb50acf50..6a4c4fa6f 100644 --- a/DashWallet/DWPhoneWCSessionManager.m +++ b/DashWallet/DWPhoneWCSessionManager.m @@ -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]; }]; diff --git a/DashWallet/DWReceiveViewController.m b/DashWallet/DWReceiveViewController.m index 62217c740..6616f8b34 100644 --- a/DashWallet/DWReceiveViewController.m +++ b/DashWallet/DWReceiveViewController.m @@ -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; @@ -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]; } @@ -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]; + }]; + } + + } }); }); @@ -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; @@ -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) { diff --git a/DashWallet/DWRootViewController.m b/DashWallet/DWRootViewController.m index 722113625..f66167a39 100644 --- a/DashWallet/DWRootViewController.m +++ b/DashWallet/DWRootViewController.m @@ -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) { @@ -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]; @@ -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 @@ -436,7 +436,7 @@ -(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]; @@ -444,7 +444,7 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken { }]; 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]; @@ -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]; @@ -465,8 +465,8 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken { }]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(chainPeerManagerNewBlockNotification) - name:DSChainPeerManagerNewBlockNotification + selector:@selector(chainNewBlockNotification) + name:DSChainNewBlockNotification object:nil]; } @@ -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) { @@ -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; @@ -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 @@ -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]; @@ -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), @@ -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]; } @@ -1363,7 +1363,7 @@ - (void)animateTransition:(id)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]; } diff --git a/DashWallet/DWScanViewController.m b/DashWallet/DWScanViewController.m index b126ae0db..97153c03f 100644 --- a/DashWallet/DWScanViewController.m +++ b/DashWallet/DWScanViewController.m @@ -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]; }); } diff --git a/DashWallet/DWSeedViewController.m b/DashWallet/DWSeedViewController.m index a6ec08124..096700f78 100644 --- a/DashWallet/DWSeedViewController.m +++ b/DashWallet/DWSeedViewController.m @@ -55,7 +55,7 @@ - (instancetype)customInit if (![DWEnvironment sharedInstance].currentWallet) { [DSWallet standardWalletWithRandomSeedPhraseForChain:[DWEnvironment sharedInstance].currentChain storeSeedPhrase:YES]; self.seedPhrase = [DWEnvironment sharedInstance].currentWallet.seedPhraseIfAuthenticated; - [[DWEnvironment sharedInstance].currentChainPeerManager connect]; + [[DWEnvironment sharedInstance].currentChainManager.peerManager connect]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:WALLET_NEEDS_BACKUP_KEY]; [[NSUserDefaults standardUserDefaults] synchronize]; } diff --git a/DashWallet/DWSendViewController.m b/DashWallet/DWSendViewController.m index 2002522cd..e2f718695 100644 --- a/DashWallet/DWSendViewController.m +++ b/DashWallet/DWSendViewController.m @@ -150,7 +150,7 @@ - (void)viewDidLoad [self checkChain]; self.chainObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerSyncStartedNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerSyncStartedNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [self checkChain]; }]; @@ -315,12 +315,12 @@ - (void)handleFile:(NSData *)file // TODO: reject payments that don't match requested amounts/scripts, implement refunds DSPaymentProtocolPayment *payment = [DSPaymentProtocolPayment paymentWithData:file onChain:[DWEnvironment sharedInstance].currentChain]; - DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager; + DSChainManager * chainManager = [DWEnvironment sharedInstance].currentChainManager; if (payment.transactions.count > 0) { for (DSTransaction *tx in payment.transactions) { [(id)self.parentViewController.parentViewController startActivityWithTimeout:30]; - [chainPeerManager publishTransaction:tx completion:^(NSError *error) { + [chainManager.transactionManager publishTransaction:tx completion:^(NSError *error) { [(id)self.parentViewController.parentViewController stopActivityWithSuccess:(! error)]; if (error) { @@ -990,7 +990,7 @@ - (void)confirmTransaction:(DSTransaction *)tx toAddress:(NSString*)address with } } else { DSAccount * account = [DWEnvironment sharedInstance].currentAccount; - DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager; + DSChainManager * chainManager = [DWEnvironment sharedInstance].currentChainManager; [account signTransaction:tx withPrompt:prompt completion:^(BOOL signedTransaction) { if (!signedTransaction) { UIAlertController * alert = [UIAlertController @@ -1023,7 +1023,7 @@ - (void)confirmTransaction:(DSTransaction *)tx toAddress:(NSString*)address with [(id)self.parentViewController.parentViewController startActivityWithTimeout:30.0]; - [chainPeerManager publishTransaction:tx completion:^(NSError *error) { + [chainManager.transactionManager publishTransaction:tx completion:^(NSError *error) { if (error) { if (! waiting && ! sent) { UIAlertController * alert = [UIAlertController @@ -1162,7 +1162,7 @@ - (void)confirmSweep:(NSString *)privKey DSAccount * account = [DWEnvironment sharedInstance].currentAccount; DSPriceManager * priceManager = [DSPriceManager sharedInstance]; - DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager; + DSChainManager * chainManager = [DWEnvironment sharedInstance].currentChainManager; [account sweepPrivateKey:privKey withFee:YES completion:^(DSTransaction *tx, uint64_t fee, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -1211,7 +1211,7 @@ - (void)confirmSweep:(NSString *)privKey handler:^(UIAlertAction * action) { [(id)self.parentViewController.parentViewController startActivityWithTimeout:30]; - [chainPeerManager publishTransaction:self.sweepTx completion:^(NSError *error) { + [chainManager.transactionManager publishTransaction:self.sweepTx completion:^(NSError *error) { [(id)self.parentViewController.parentViewController stopActivityWithSuccess:(! error)]; if (error) { diff --git a/DashWallet/DWSettingsViewController.m b/DashWallet/DWSettingsViewController.m index 88d8d098a..8ce6096d4 100644 --- a/DashWallet/DWSettingsViewController.m +++ b/DashWallet/DWSettingsViewController.m @@ -79,7 +79,7 @@ - (void)viewWillAppear:(BOOL)animated if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerTransactionStatusDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [(id)[self.navigationController.topViewController.view viewWithTag:412] setTitle:self.stats forState:UIControlStateNormal]; @@ -130,7 +130,7 @@ - (NSString *)stats static NSDateFormatter *fmt = nil; DSPriceManager * priceManager = [DSPriceManager sharedInstance]; DSChain * chain = [DWEnvironment sharedInstance].currentChain; - DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager; + DSPeerManager * peerManager = [DWEnvironment sharedInstance].currentChainManager.peerManager; if (! fmt) { fmt = [NSDateFormatter new]; @@ -144,8 +144,8 @@ - (NSString *)stats [fmt stringFromDate:[NSDate dateWithTimeIntervalSince1970:[DSAuthenticationManager sharedInstance].secureTime]].lowercaseString, chain.lastBlockHeight, chain.estimatedBlockHeight, - chainPeerManager.peerCount, - chainPeerManager.downloadPeerName]; + peerManager.peerCount, + peerManager.downloadPeerName]; } -(BOOL)enabledAdvancedFeatures { @@ -256,8 +256,8 @@ - (IBAction)fixedPeer:(id)sender [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%@:%d", host, port] forKey:SETTINGS_FIXED_PEER_KEY]; - [[DWEnvironment sharedInstance].currentChainPeerManager disconnect]; - [[DWEnvironment sharedInstance].currentChainPeerManager connect]; + [[DWEnvironment sharedInstance].currentChainManager.peerManager disconnect]; + [[DWEnvironment sharedInstance].currentChainManager.peerManager connect]; break; } @@ -284,8 +284,8 @@ - (IBAction)fixedPeer:(id)sender style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { [[NSUserDefaults standardUserDefaults] removeObjectForKey:SETTINGS_FIXED_PEER_KEY]; - [[DWEnvironment sharedInstance].currentChainPeerManager disconnect]; - [[DWEnvironment sharedInstance].currentChainPeerManager connect]; + [[DWEnvironment sharedInstance].currentChainManager.peerManager disconnect]; + [[DWEnvironment sharedInstance].currentChainManager.peerManager connect]; }]; [alert addAction:clearButton]; [alert addAction:cancelButton]; @@ -709,7 +709,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath { //TODO: include an option to generate a new wallet and sweep old balance if backup may have been compromized DSPriceManager * priceManager = [DSPriceManager sharedInstance]; - DSChainPeerManager * chainPeerManager = [DWEnvironment sharedInstance].currentChainPeerManager; + DSChainManager * chainManager = [DWEnvironment sharedInstance].currentChainManager; DSAuthenticationManager * authenticationManager = [DSAuthenticationManager sharedInstance]; NSUInteger currencyCodeIndex = 0; @@ -782,7 +782,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath break; case 2: // rescan blockchain - [chainPeerManager rescan]; + [chainManager rescan]; [DSEventManager saveEvent:@"settings:rescan"]; [self done:nil]; break; diff --git a/DashWallet/DWTxDetailViewController.m b/DashWallet/DWTxDetailViewController.m index 002e2eca8..5ba56665d 100644 --- a/DashWallet/DWTxDetailViewController.m +++ b/DashWallet/DWTxDetailViewController.m @@ -53,7 +53,7 @@ - (void)viewWillAppear:(BOOL)animated if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerTransactionStatusDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { DSTransaction *tx = [[DWEnvironment sharedInstance].currentAccount transactionForHash:self.transaction.txHash]; @@ -203,9 +203,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N UITableViewCell *cell; BRCopyLabel *detailLabel; UILabel *textLabel, *subtitleLabel, *amountLabel, *localCurrencyLabel; - DSChainPeerManager *manager = [DWEnvironment sharedInstance].currentChainPeerManager; - NSUInteger peerCount = manager.peerCount; - NSUInteger relayCount = [manager relayCountForTransaction:self.transaction.txHash]; + DSChainManager *manager = [DWEnvironment sharedInstance].currentChainManager; + NSUInteger peerCount = manager.peerManager.peerCount; + NSUInteger relayCount = [manager.transactionManager relayCountForTransaction:self.transaction.txHash]; NSString *s; NSInteger indexPathRow = indexPath.row; diff --git a/DashWallet/DWTxHistoryViewController.m b/DashWallet/DWTxHistoryViewController.m index 1198efec7..d9e14b14d 100644 --- a/DashWallet/DWTxHistoryViewController.m +++ b/DashWallet/DWTxHistoryViewController.m @@ -137,7 +137,7 @@ - (void)viewWillAppear:(BOOL)animated if (! self.txStatusObserver) { self.txStatusObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:DSChainPeerManagerTxStatusNotification object:nil + [[NSNotificationCenter defaultCenter] addObserverForName:DSTransactionManagerTransactionStatusDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { self.transactions = account.allTransactions; [self.tableView reloadData];