Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Refresh quicker until daemon is online.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitspill committed Oct 13, 2015
1 parent 048ab69 commit a0f7e33
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions app/plugins/Wallet/js/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

var blockheight = 0;

// How often /wallet updates
var refreshRate = 500; // half-second
var finalRefreshRate = 1000 * 60 * 5; // five-minutes

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Updating ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Make API calls, sending a channel name to listen for responses
function update(address) {
Expand All @@ -13,8 +17,7 @@ function update(address) {
type: 'GET',
}, 'update-address');

updating = setTimeout(update, 60000 * 5); // update every 5 min
return;
updating = setTimeout(update, refreshRate);
}

// Add transactions to view list per address
Expand All @@ -24,7 +27,6 @@ addResultListener('update-address', function(result) {
result.addresses.forEach( function (address) {
appendAddress(address);
});
return;

/* Fetch all wallet transactions by iterate over wallet addresses
var loopmax = result.addresses.length;
Expand All @@ -46,8 +48,20 @@ function updateAddrTxn(addr) {
}, 'update-history');
}

// Update wallet summary in header
// Update transaction history and addresses
addResultListener('update-status', function(wallet) {
refreshRate = finalRefreshRate; // slow down after first successful call

// Show correct lock status.
// TODO: If the wallet is encrypted, prompt with a pw.
if (!wallet.encrypted) {
setUnencrypted();
} else if (!wallet.unlocked) {
setLocked();
} else if (wallet.unlocked) {
setUnlocked();
}

// Update balance confirmed and uncomfirmed
var bal = convertSiacoin(wallet.confirmedsiacoinbalance);
var pend = convertSiacoin(wallet.unconfirmedincomingsiacoins).sub(convertSiacoin(wallet.unconfirmedoutgoingsiacoins));
Expand Down Expand Up @@ -83,7 +97,6 @@ function appendAddress(addr) {
// Display address
eID('address-list').appendChild(addrElement);
show(addrElement);
return;
}
function getAddress(event) {
updateAddrTxn(event.target.id);
Expand Down Expand Up @@ -147,7 +160,6 @@ function appendTransaction(txn) {
// Display transaction
eID('transaction-list').appendChild(txnElement);
show(txnElement);
return;
}

// Update transaction history
Expand All @@ -172,27 +184,8 @@ function start() {
// DEVTOOL: uncomment to bring up devtools on plugin view
// IPC.sendToHost('devtools');

// Need to check if wallet's unencrypted
IPC.sendToHost('api-call', '/wallet', 'on-opened');
}

// First status call to diagnose the state of the wallet
addResultListener('on-opened', function(result) {
wallet = result;

// Show correct lock status. TODO: If the wallet is encrypted, prompt with
// a pw.
if (!wallet.encrypted) {
setUnencrypted();
} else if (!wallet.unlocked) {
setLocked();
} else if (wallet.unlocked) {
setUnlocked();
}

// Start updating
update();
});
}

// Called upon transitioning away from this view
function stop() {
Expand Down

0 comments on commit a0f7e33

Please sign in to comment.