! handle the clean transactions correctly before fully synced

! sync all wallets correctly
This commit is contained in:
Taegus
2018-12-28 15:25:39 +01:00
parent 1c629801c4
commit 19a7052398
5 changed files with 61 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "Ether1Wallet", "name": "Ether1Wallet",
"version": "0.1.3", "version": "0.2.1",
"description": "Desktop wallet for Ether1 currency", "description": "Desktop wallet for Ether1 currency",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@@ -230,6 +230,7 @@ class Blockchain {
} }
unsubsribePendingTransactions(clbError, clbSuccess) { unsubsribePendingTransactions(clbError, clbSuccess) {
if (this.txSubscribe) {
this.txSubscribe.unsubscribe(function(error, success){ this.txSubscribe.unsubscribe(function(error, success){
if(error) { if(error) {
clbError(error); clbError(error);
@@ -238,6 +239,7 @@ class Blockchain {
} }
}); });
} }
}
subsribeNewBlockHeaders(clbError, clbSuccess, clbData) { subsribeNewBlockHeaders(clbError, clbSuccess, clbData) {
this.bhSubscribe = web3Local.eth.subscribe('newBlockHeaders', function(error, result){ this.bhSubscribe = web3Local.eth.subscribe('newBlockHeaders', function(error, result){
@@ -254,6 +256,7 @@ class Blockchain {
} }
unsubsribeNewBlockHeaders(clbError, clbSuccess) { unsubsribeNewBlockHeaders(clbError, clbSuccess) {
if (this.bhSubscribe) {
this.bhSubscribe.unsubscribe(function(error, success){ this.bhSubscribe.unsubscribe(function(error, success){
if(error) { if(error) {
clbError(error); clbError(error);
@@ -262,6 +265,7 @@ class Blockchain {
} }
}); });
} }
}
closeConnection() { closeConnection() {
web3Local.currentProvider.connection.close(); web3Local.currentProvider.connection.close();

View File

@@ -12,6 +12,7 @@ class Settings {
$(document).on("render_settings", function() { $(document).on("render_settings", function() {
$("#btnSettingsCleanTransactions").off('click').on('click', function() { $("#btnSettingsCleanTransactions").off('click').on('click', function() {
if (isFullySynced) {
EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function(result) { EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function(result) {
if (result) { if (result) {
if (EthoTransactions.getIsSyncing()) { if (EthoTransactions.getIsSyncing()) {
@@ -43,6 +44,14 @@ $(document).on("render_settings", function() {
} }
} }
}); });
} else {
iziToast.info({
title: 'Wait...',
message: 'You need to be fully sync before cleaning transactions',
position: 'topRight',
timeout: 5000
});
}
}); });
$("#btnSettingsCleanWallets").off('click').on('click', function() { $("#btnSettingsCleanWallets").off('click').on('click', function() {

View File

@@ -29,6 +29,7 @@ SyncProgress = new ProgressBar.Line('#syncProgress',
// set initial value for the progress text // set initial value for the progress text
SyncProgress.setText("Waiting for blockchain, please wait..."); SyncProgress.setText("Waiting for blockchain, please wait...");
isFullySynced = false;
var peerCountInterval = setInterval(function() var peerCountInterval = setInterval(function()
{ {
@@ -62,6 +63,7 @@ function StartSyncProcess() {
// clear the repeat interval and render wallets // clear the repeat interval and render wallets
$(document).trigger("onNewAccountTransaction"); $(document).trigger("onNewAccountTransaction");
alreadyCatchedUp = true; alreadyCatchedUp = true;
isFullySynced = true;
// enable the keep in sync feature // enable the keep in sync feature
EthoTransactions.enableKeepInSync(); EthoTransactions.enableKeepInSync();

View File

@@ -27,7 +27,7 @@ class Transactions {
} }
syncTransactionsForSingleAddress(addressList, counters, lastBlock, counter) { syncTransactionsForSingleAddress(addressList, counters, lastBlock, counter) {
if (counter < addressList.length - 1) { if (counter < addressList.length) {
SyncProgress.setText(vsprintf("Syncing address transactions %d/%d, please wait...", [counter, addressList.length])); SyncProgress.setText(vsprintf("Syncing address transactions %d/%d, please wait...", [counter, addressList.length]));
var startBlock = parseInt(counters.transactions) || 0; var startBlock = parseInt(counters.transactions) || 0;