Commit 2f255289 authored by Eriksson Monteiro's avatar Eriksson Monteiro

add sync switch. update wallet ui and millix node

parent d115025a
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@
<br>
<a href="#"><img src="https://github.com/millix/millix-wallet/blob/master/app/icon.png?raw=true" alt="millix node" width="200"></a>
<br>
millix node <small>v1.16.3</small>
millix node <small>v1.17.0</small>
<br>
</h1>
......
......@@ -13,6 +13,13 @@ class _ConfigLoader {
'TRANSACTION_OUTPUT_MAX',
'TRANSACTION_PARENT_MAX',
'TRANSACTION_SIGNATURE_MAX',
'DEBUG_LOG_FILTER',
'FORCE_QUEUE_UPDATE',
'MODE_NODE_VALIDATION_FULL',
'NETWORK_LONG_TIME_WAIT_MAX',
'NETWORK_SHORT_TIME_WAIT_MAX',
'TRANSACTION_TIME_LIMIT_PROXY',
'TRANSACTION_CLOCK_SKEW_TOLERANCE',
'TRANSACTION_OUTPUT_REFRESH_OLDER_THAN',
'TRANSACTION_OUTPUT_EXPIRE_OLDER_THAN',
'WALLET_TRANSACTION_DEFAULT_VERSION',
......
......@@ -15,7 +15,8 @@ export const NODE_NAT_PMP_CHECK = true;
export const WEBSOCKET_PROTOCOL = 'wss://';
export const RPC_INTERFACE = '0.0.0.0';
export const NODE_PUBLIC = true;
export const MODE_NODE_FULL = true;
export const MODE_NODE_VALIDATION_FULL = true;
export const MODE_NODE_SYNC_FULL = false;
export const FORCE_QUEUE_UPDATE = false;
export const EXTERNAL_WALLET_KEY_IDENTIFIER = [];
export const NODE_INITIAL_LIST_MAIN_NETWORK = [
......@@ -778,8 +779,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500;
export const DATABASE_ENGINE = 'sqlite';
export const DATABASE_CONNECTION = {};
export const MILLIX_CIRCULATION = 9e15;
export const NODE_MILLIX_BUILD_DATE = 1648494468;
export const NODE_MILLIX_VERSION = '1.16.3-tangled';
export const NODE_MILLIX_BUILD_DATE = 1649083382;
export const NODE_MILLIX_VERSION = '1.17.0-tangled';
export const DATA_BASE_DIR_MAIN_NETWORK = './millix-tangled';
export const DATA_BASE_DIR_TEST_NETWORK = './millix-tangled';
let DATA_BASE_DIR = MODE_TEST_NETWORK ? DATA_BASE_DIR_TEST_NETWORK : DATA_BASE_DIR_MAIN_NETWORK;
......@@ -829,7 +830,8 @@ if (DATABASE_ENGINE === 'sqlite') {
export default {
MODE_DEBUG,
MODE_NODE_FULL,
MODE_NODE_SYNC_FULL,
MODE_NODE_VALIDATION_FULL,
FORCE_QUEUE_UPDATE,
MODE_TEST_NETWORK,
NODE_PORT,
......
......@@ -40,6 +40,7 @@ class Wallet {
this._transactionRequested = {};
this._transactionFundingActiveWallet = {};
this.defaultKeyIdentifier = undefined;
this.walletSyncTimeoutHandler = undefined;
this._lockProcessNewTransaction = 0;
this._maxBacklogThresholdReached = false;
this.initialized = false;
......@@ -532,6 +533,7 @@ class Wallet {
}
cache.setCacheItem('wallet', 'is_wallet_transaction_synced', true, 300000); /* do sync again on a new connection after 5min */
this.walletSyncTimeoutHandler = setTimeout(() => cache.removeCacheItem('wallet', 'is_wallet_transaction_synced'), 60000); /* 60 second timeout then request sync from another peer*/
return new Promise(resolve => {
mutex.lock(['sync-wallet-balance-request'], unlock => {
......@@ -963,8 +965,8 @@ class Wallet {
walletSync.clearTransactionSync(transaction.transaction_id);
if (config.MODE_NODE_SYNC_FULL || hasKeyIdentifier) {
this.transactionSpendRequest(transaction.transaction_id, syncPriority).then(_ => _).catch(_ => _);
walletSync.syncTransactionSpendingOutputs(transaction);
if (transaction.transaction_id !== genesisConfig.genesis_transaction) {
......@@ -1011,12 +1013,14 @@ class Wallet {
}
});
}
}
if (!isRequestedBySync || hasKeyIdentifier) {
let ws = network.getWebSocketByID(connectionID);
peer.transactionSend(data.transaction, ws);
}
if (hasTransaction) {
if (hasKeyIdentifier) {
setTimeout(() => walletTransactionConsensus.doValidateTransaction(), 0);
}
......@@ -1197,6 +1201,7 @@ class Wallet {
}
_onSyncWalletBalanceResponse(data, ws) {
clearTimeout(this.walletSyncTimeoutHandler);
mutex.lock(['sync-wallet-balance-response'], unlock => {
const transactions = data.transaction_id_list || [];
async.eachSeries(transactions, (transactionID, callback) => {
......@@ -1577,7 +1582,7 @@ class Wallet {
if (err.cause === 'consensus_timeout') {
return;
}
else if (err.cause === 'transaction_not_found') {
else if (err.cause === 'transaction_not_found' && config.MODE_NODE_SYNC_FULL) {
ws && peer.transactionSyncByWebSocket(err.transaction_id_fail, ws).then(_ => _);
this.requestTransactionFromNetwork(err.transaction_id_fail);
}
......
......@@ -627,12 +627,26 @@ export class Database {
is_sticky: true,
timestamp: Date.now()
});
if (err.message && err.message.startsWith('SQLITE_CORRUPT')) {
const dbFile = path.join(this.databaseRootFolder, config.DATABASE_CONNECTION.FILENAME_MILLIX);
return Database.deleteCorruptedDatabase(dbFile)
.then(() => this._initializeMillixSqlite3())
.then(() => this._migrateTables());
}
throw Error('[database] migration ' + err.message);
}
});
});
}
static deleteCorruptedDatabase(databaseFile) {
return new Promise(resolve => {
fs.unlink(databaseFile, err => {
resolve();
});
});
}
initialize() {
if (config.DATABASE_ENGINE === 'sqlite') {
return this._initializeMillixSqlite3()
......
......@@ -19,8 +19,8 @@ export default class Shard {
initialize() {
if (config.DATABASE_ENGINE === 'sqlite') {
return this._initializeMillixShardSqlite3()
.then(() => this._attachShardZero())
.then(() => this._migrateTables())
.then(() => this._attachShardZero())
.then(() => this._initializeTables());
}
return Promise.resolve();
......@@ -73,6 +73,13 @@ export default class Shard {
is_sticky: true,
timestamp: Date.now()
});
if (err.message && err.message.startsWith('SQLITE_CORRUPT')) {
return Database.deleteCorruptedDatabase(this.databaseFile)
.then(() => this._initializeMillixShardSqlite3())
.then(() => this._migrateTables());
}
throw Error('[shard] migration ' + err.message);
});
});
......
......@@ -125,7 +125,7 @@ db.initialize()
});
}
});
//millix v1.16.3-tangled
//millix v1.17.0-tangled
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment