+ clean blockchain data

* show sender wallet name and only show address in the main field
This commit is contained in:
Taegus
2019-02-03 12:51:00 +01:00
parent 91356cfc8f
commit 69ffad124d
7 changed files with 102 additions and 36 deletions

View File

@@ -6,15 +6,16 @@ const os = require('os');
class Accounts {
constructor() {
this.getKeyStoreLocation = function() {
switch(os.type()) {
case "Darwin":
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore');
break;
default:
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
}
}
}
getKeyStoreLocation() {
switch(os.type()) {
case "Darwin":
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore');
break;
default:
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
}
}
exportAccounts() {
@@ -23,7 +24,7 @@ class Accounts {
});
if (savePath) {
const accPath = this.getKeyStoreLocation();
const accPath = EthoAccounts.getKeyStoreLocation();
fs.readdir(accPath, function(err, files) {
var zip = new admZip();
@@ -40,7 +41,7 @@ class Accounts {
importAccounts(accountsFile) {
var extName = path.extname(accountsFile).toUpperCase();
const accPath = this.getKeyStoreLocation();
const accPath = EthoAccounts.getKeyStoreLocation();
if (extName == '.ZIP') {
var zip = new admZip(accountsFile);
@@ -57,7 +58,7 @@ class Accounts {
}
saveAccount(account) {
fs.writeFile(path.join(this.getKeyStoreLocation(), '0x' + account.address), JSON.stringify(account), 'utf8', function() {
fs.writeFile(path.join(tEthoAccountshis.getKeyStoreLocation(), '0x' + account.address), JSON.stringify(account), 'utf8', function() {
// file was written
});
}

View File

@@ -4,6 +4,7 @@ const datastore = require('nedb');
const moment = require('moment');
const path = require('path');
const fs = require('fs');
const os = require('os');
const dbPath = path.join(app.getPath('userData'), 'storage.db');
const db = new datastore({ filename: dbPath });
@@ -96,5 +97,35 @@ ipcMain.on('deleteWalletData', (event, arg) => {
} else {
event.returnValue = { success: true, error: null };
}
});
});
});
});
ipcMain.on('deleteBlockchainData', (event, arg) => {
var deleteFolderRecursive = function(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
function getBlockchainDataLocation() {
switch(os.type()) {
case "Darwin":
return path.join(os.homedir(), 'Library', 'Ether1', 'geth');
break;
default:
return path.join(process.env.APPDATA, 'Ether1', 'geth');
}
}
// delete folder in a synchronous recursive maner
deleteFolderRecursive(getBlockchainDataLocation());
event.returnValue = true;
});

View File

@@ -1,5 +1,5 @@
const {app, dialog, ipcMain} = require('electron');
const child_process = require('child_process');
const {app, dialog} = require('electron');
const appRoot = require('app-root-path');
const path = require('path');
const fs = require('fs');
@@ -79,4 +79,8 @@ class Geth {
}
}
ipcMain.on('stopGeth', (event, arg) => {
EthoGeth.stopGeth();
});
EthoGeth = new Geth();