Commit 53fbe297 authored by Jeremy Bokobza's avatar Jeremy Bokobza Committed by GitHub

Merge pull request #112 from bokobza/master

Removed waiting for chain download
parents 8c2d76d9 62a6e65c
...@@ -35,15 +35,12 @@ namespace Breeze.Wallet ...@@ -35,15 +35,12 @@ namespace Breeze.Wallet
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task Initialize() public Task Initialize()
{ {
this.walletTip = this.chain.GetBlock(this.walletManager.WalletTipHash); this.walletTip = this.chain.GetBlock(this.walletManager.WalletTipHash);
if (this.walletTip == null) if (this.walletTip == null)
throw new WalletException("the wallet tip was not found in the main chain"); throw new WalletException("the wallet tip was not found in the main chain");
// get the chain headers. This needs to be up-to-date before we really do anything
await this.WaitForChainDownloadAsync();
// if there is no wallet created yet, the wallet tip is the chain tip. // if there is no wallet created yet, the wallet tip is the chain tip.
if (!this.walletManager.Wallets.Any()) if (!this.walletManager.Wallets.Any())
{ {
...@@ -57,10 +54,11 @@ namespace Breeze.Wallet ...@@ -57,10 +54,11 @@ namespace Breeze.Wallet
txSub.Subscribe(); txSub.Subscribe();
// start syncing blocks // start syncing blocks
var bestHeightForSyncing = this.FindBestHeightForSyncing(); var bestHeightForSyncing = this.FindBestHeightForSyncing();
this.blockNotification.SyncFrom(this.chain.GetBlock(bestHeightForSyncing).HashBlock); this.blockNotification.SyncFrom(this.chain.GetBlock(bestHeightForSyncing).HashBlock);
this.logger.LogInformation($"Tracker initialized. Syncing from {bestHeightForSyncing}."); this.logger.LogInformation($"Tracker initialized. Syncing from {bestHeightForSyncing}.");
return Task.CompletedTask;
} }
private int FindBestHeightForSyncing() private int FindBestHeightForSyncing()
...@@ -160,7 +158,7 @@ namespace Breeze.Wallet ...@@ -160,7 +158,7 @@ namespace Breeze.Wallet
throw new WalletException("Invalid block height"); throw new WalletException("Invalid block height");
this.walletTip = chainedBlock; this.walletTip = chainedBlock;
this.walletManager.WalletTipHash = chainedBlock.HashBlock; this.walletManager.WalletTipHash = chainedBlock.HashBlock;
this.blockNotification.SyncFrom(chainedBlock.HashBlock);
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment