! 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",
"version": "0.1.3",
"version": "0.2.1",
"description": "Desktop wallet for Ether1 currency",
"main": "main.js",
"scripts": {

View File

@@ -230,13 +230,15 @@ class Blockchain {
}
unsubsribePendingTransactions(clbError, clbSuccess) {
this.txSubscribe.unsubscribe(function(error, success){
if(error) {
clbError(error);
} else {
clbSuccess(success) ;
}
});
if (this.txSubscribe) {
this.txSubscribe.unsubscribe(function(error, success){
if(error) {
clbError(error);
} else {
clbSuccess(success) ;
}
});
}
}
subsribeNewBlockHeaders(clbError, clbSuccess, clbData) {
@@ -254,13 +256,15 @@ class Blockchain {
}
unsubsribeNewBlockHeaders(clbError, clbSuccess) {
this.bhSubscribe.unsubscribe(function(error, success){
if(error) {
clbError(error);
} else {
clbSuccess(success) ;
}
});
if (this.bhSubscribe) {
this.bhSubscribe.unsubscribe(function(error, success){
if(error) {
clbError(error);
} else {
clbSuccess(success) ;
}
});
}
}
closeConnection() {

View File

@@ -12,37 +12,46 @@ class Settings {
$(document).on("render_settings", function() {
$("#btnSettingsCleanTransactions").off('click').on('click', function() {
EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function(result) {
if (result) {
if (EthoTransactions.getIsSyncing()) {
EthoMainGUI.showGeneralError("Transactions sync is currently in progress");
} else {
// first disable keepInSync
EthoTransactions.disableKeepInSync();
// then delete the transactions data
var counters = EthoDatatabse.getCounters();
counters.transactions = 0;
EthoDatatabse.setCounters(counters);
ipcRenderer.sendSync('deleteTransactions', null);
// sync all the transactions to the current block
web3Local.eth.getBlock("latest", function(error, localBlock) {
if (error) {
EthoMainGUI.showGeneralError(error);
} else {
EthoTransactions.enableKeepInSync();
EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
if (isFullySynced) {
EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function(result) {
if (result) {
if (EthoTransactions.getIsSyncing()) {
EthoMainGUI.showGeneralError("Transactions sync is currently in progress");
} else {
// first disable keepInSync
EthoTransactions.disableKeepInSync();
// then delete the transactions data
var counters = EthoDatatabse.getCounters();
counters.transactions = 0;
EthoDatatabse.setCounters(counters);
ipcRenderer.sendSync('deleteTransactions', null);
// sync all the transactions to the current block
web3Local.eth.getBlock("latest", function(error, localBlock) {
if (error) {
EthoMainGUI.showGeneralError(error);
} else {
EthoTransactions.enableKeepInSync();
EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
iziToast.success({
title: 'Success',
message: 'Transactions are being resynced',
position: 'topRight',
timeout: 5000
});
}
});
iziToast.success({
title: 'Success',
message: 'Transactions are being resynced',
position: 'topRight',
timeout: 5000
});
}
});
}
}
}
});
});
} 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() {

View File

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

View File

@@ -27,7 +27,7 @@ class Transactions {
}
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]));
var startBlock = parseInt(counters.transactions) || 0;