Wallet: async fetching wallet, daemon and target height

This commit is contained in:
xiphon
2019-06-13 12:19:52 +00:00
parent 68c7cf7276
commit 2524cc179e
3 changed files with 38 additions and 21 deletions

View File

@@ -293,6 +293,7 @@ ApplicationWindow {
// Disconnect all listeners
if (typeof currentWallet !== "undefined" && currentWallet !== null) {
currentWallet.heightRefreshed.disconnect(onHeightRefreshed);
currentWallet.refreshed.disconnect(onWalletRefresh)
currentWallet.updated.disconnect(onWalletUpdate)
currentWallet.newBlock.disconnect(onWalletNewBlock)
@@ -351,6 +352,7 @@ ApplicationWindow {
}
// connect handlers
currentWallet.heightRefreshed.connect(onHeightRefreshed);
currentWallet.refreshed.connect(onWalletRefresh)
currentWallet.updated.connect(onWalletUpdate)
currentWallet.newBlock.connect(onWalletNewBlock)
@@ -621,18 +623,7 @@ ApplicationWindow {
remoteNodeConnected = false;
}
function onWalletRefresh() {
console.log(">>> wallet refreshed")
// Daemon connected
leftPanel.networkStatus.connected = currentWallet.connected()
// Wallet height
var bcHeight = currentWallet.blockChainHeight();
// Check daemon status
var dCurrentBlock = currentWallet.daemonBlockChainHeight();
var dTargetBlock = currentWallet.daemonBlockChainTargetHeight();
function onHeightRefreshed(bcHeight, dCurrentBlock, dTargetBlock) {
// Daemon fully synced
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
// targetBlock = currentBlock = 1 before network connection is established.
@@ -683,6 +674,15 @@ ApplicationWindow {
onWalletUpdate();
}
function onWalletRefresh() {
console.log(">>> wallet refreshed")
// Daemon connected
leftPanel.networkStatus.connected = currentWallet.connected()
currentWallet.refreshHeightAsync();
}
function startDaemon(flags){
// Pause refresh while starting daemon
currentWallet.pauseRefresh();