Commit 9e2dddfb authored by Eriksson Monteiro's avatar Eriksson Monteiro

update millix-node v1.11.3

parent c0d769d5
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<br> <br>
<a href="#"><img src="https://github.com/millix/millix-wallet/blob/master/app/icon.png?raw=true" alt="millix node" width="200"></a> <a href="#"><img src="https://github.com/millix/millix-wallet/blob/master/app/icon.png?raw=true" alt="millix node" width="200"></a>
<br> <br>
millix node <small>v1.11.2</small> millix node <small>v1.11.3</small>
<br> <br>
</h1> </h1>
......
...@@ -774,8 +774,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500; ...@@ -774,8 +774,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500;
export const DATABASE_ENGINE = 'sqlite'; export const DATABASE_ENGINE = 'sqlite';
export const DATABASE_CONNECTION = {}; export const DATABASE_CONNECTION = {};
export const MILLIX_CIRCULATION = 9e15; export const MILLIX_CIRCULATION = 9e15;
export const NODE_MILLIX_BUILD_DATE = 1629213000; export const NODE_MILLIX_BUILD_DATE = 1629385375;
export const NODE_MILLIX_VERSION = '1.11.2-tangled'; export const NODE_MILLIX_VERSION = '1.11.3-tangled';
export const DATA_BASE_DIR_MAIN_NETWORK = './millix-tangled'; export const DATA_BASE_DIR_MAIN_NETWORK = './millix-tangled';
export const DATA_BASE_DIR_TEST_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; let DATA_BASE_DIR = MODE_TEST_NETWORK ? DATA_BASE_DIR_TEST_NETWORK : DATA_BASE_DIR_MAIN_NETWORK;
...@@ -786,6 +786,7 @@ export const WALLET_KEY_PATH = DATA_BASE_DIR + ...@@ -786,6 +786,7 @@ export const WALLET_KEY_PATH = DATA_BASE_DIR +
export const JOB_CONFIG_PATH = DATA_BASE_DIR + '/job.json'; export const JOB_CONFIG_PATH = DATA_BASE_DIR + '/job.json';
export const JOB_CONFIG_VERSION = 4; export const JOB_CONFIG_VERSION = 4;
export const SHARD_ZERO_NAME = 'shard_zero'; export const SHARD_ZERO_NAME = 'shard_zero';
export const DEBUG_LOG_FILTER = [];
export const PEER_ROTATION_MORE_THAN_AVERAGE = 0.5; export const PEER_ROTATION_MORE_THAN_AVERAGE = 0.5;
export const PEER_ROTATION_MORE_THAN_MOST = 0.2; export const PEER_ROTATION_MORE_THAN_MOST = 0.2;
export const PEER_ROTATION_MORE_THAN_ALL = 0.01; export const PEER_ROTATION_MORE_THAN_ALL = 0.01;
...@@ -893,5 +894,6 @@ export default { ...@@ -893,5 +894,6 @@ export default {
PEER_ROTATION_MORE_THAN_ALL, PEER_ROTATION_MORE_THAN_ALL,
PEER_ROTATION_CONFIG, PEER_ROTATION_CONFIG,
JOB_CONFIG_PATH, JOB_CONFIG_PATH,
JOB_CONFIG_VERSION JOB_CONFIG_VERSION,
DEBUG_LOG_FILTER
}; };
...@@ -19,4 +19,6 @@ console.log = function() { ...@@ -19,4 +19,6 @@ console.log = function() {
enabled && showLog && config.MODE_DEBUG && _consoleLog.apply(console, arguments); enabled && showLog && config.MODE_DEBUG && _consoleLog.apply(console, arguments);
}; };
config.DEBUG_LOG_FILTER.forEach(filter => console.addFilter(filter));
export default console; export default console;
...@@ -29,7 +29,13 @@ class Task { ...@@ -29,7 +29,13 @@ class Task {
}); });
} }
else { else {
try {
task(); task();
}
catch (e) {
this.debug && console.log(`[task] error running task ${taskName}: ${e}`);
}
if (!once) { if (!once) {
self.runningTask[taskName] = setTimeout(run, waitTime); self.runningTask[taskName] = setTimeout(run, waitTime);
} }
......
...@@ -225,7 +225,7 @@ export class WalletTransactionConsensus { ...@@ -225,7 +225,7 @@ export class WalletTransactionConsensus {
message : `not validated in a depth of ${depth}` message : `not validated in a depth of ${depth}`
}); });
} }
else if (transaction.status === 2 || database.getRepository('transaction').isExpired(transaction.transaction_date)) { else if (transaction && (transaction.status === 2 || database.getRepository('transaction').isExpired(transaction.transaction_date))) {
return reject({ return reject({
cause : 'transaction_validation_max_depth', cause : 'transaction_validation_max_depth',
transaction_id_fail: transactionID, transaction_id_fail: transactionID,
......
...@@ -108,4 +108,4 @@ db.initialize() ...@@ -108,4 +108,4 @@ db.initialize()
}); });
} }
}); });
//millix v1.11.2-tangled //millix v1.11.3-tangled
...@@ -19,6 +19,8 @@ import os from 'os'; ...@@ -19,6 +19,8 @@ import os from 'os';
class JobEngine { class JobEngine {
static JOB_WAIT_TIME = 1000;
constructor() { constructor() {
this.debug = false; this.debug = false;
this.configJobEngine = null; this.configJobEngine = null;
...@@ -93,21 +95,26 @@ class JobEngine { ...@@ -93,21 +95,26 @@ class JobEngine {
this.debug && console.log(`[job-engine] running job ${job.job_id} : ${job.job_name}`); this.debug && console.log(`[job-engine] running job ${job.job_id} : ${job.job_name}`);
let unlocked = false; let unlocked = false;
const timestampBegin = ntp.now(); const timestampBegin = ntp.now();
this.jobRepository.updateJobProgressStatus(job.job_id, 1, {last_date_begin: timestampBegin}) const payload = JSON.parse(job.job_payload);
const module = payload ? this.modules[payload.module] : undefined;
return this.jobRepository.updateJobProgressStatus(job.job_id, 1, {last_date_begin: timestampBegin})
.then(() => this.jobRepository.lockJobObject(job.job_id)) .then(() => this.jobRepository.lockJobObject(job.job_id))
.then(() => { .then(() => {
unlock(); unlock();
unlocked = true; unlocked = true;
// run job // run job
if (job.job_type_id === this.types['function']) { if (job.job_type_id === this.types['function']) {
const payload = JSON.parse(job.job_payload);
const module = this.modules[payload.module];
this.debug && console.log(`[job-engine] running function ${payload.module}:${payload.function_name}`); this.debug && console.log(`[job-engine] running function ${payload.module}:${payload.function_name}`);
if (!module || !payload || !module[payload.function_name]) {
return Promise.reject('job_invalid');
}
let postJob = () => { let postJob = () => {
const timestampEnd = ntp.now(); const timestampEnd = ntp.now();
const lastElapse = timestampEnd.getTime() - timestampBegin.getTime(); const lastElapse = timestampEnd.getTime() - timestampBegin.getTime();
this.debug && console.log(`[job-engine] done ${payload.module}:${payload.function_name} - ${lastElapse} ms`); this.debug && console.log(`[job-engine] done ${payload.module}:${payload.function_name} - ${lastElapse} ms`);
return new Promise((resolve, reject) => {
mutex.lock(['job-engine'], (unlockUpdate) => { mutex.lock(['job-engine'], (unlockUpdate) => {
this.jobRepository.updateJobProgressStatus(job.job_id, 0, { this.jobRepository.updateJobProgressStatus(job.job_id, 0, {
last_date_end: timestampEnd, last_date_end: timestampEnd,
...@@ -116,45 +123,29 @@ class JobEngine { ...@@ -116,45 +123,29 @@ class JobEngine {
}) })
.then(() => this.jobRepository.unlockJobObject(job.job_id)) .then(() => this.jobRepository.unlockJobObject(job.job_id))
.then(() => { .then(() => {
this.processorsStatus[processorTag]['running'] = false;
unlockUpdate(); unlockUpdate();
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true); resolve();
}) })
.catch(() => { .catch(() => {
this.processorsStatus[processorTag]['running'] = false;
unlockUpdate(); unlockUpdate();
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true); reject();
});
}); });
}); });
}; };
module[payload.function_name]() return module[payload.function_name]()
.then(postJob) .then(postJob)
.catch(postJob); .catch(postJob);
} }
else { else {
mutex.lock(['job-engine'], (unlockUpdate) => { return Promise.reject('job_not_supported');
this.jobRepository
.updateJobProgressStatus(job.job_id, 0, {
last_date_end: ntp.now(),
last_elapse : 0,
last_response: 'fail'
})
.then(() => this.jobRepository.unlockJobObject(job.job_id))
.then(() => {
this.processorsStatus[processorTag]['running'] = false;
unlockUpdate();
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true);
})
.catch(() => {
this.processorsStatus[processorTag]['running'] = false;
unlockUpdate();
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true);
});
});
} }
}) })
.catch(() => { .catch(() => {
const timestampEnd = ntp.now();
const lastElapse = timestampEnd.getTime() - timestampBegin.getTime();
this.debug && console.log(`[job-engine] done ${payload.module}:${payload.function_name} - ${lastElapse} ms`);
mutex.lock(['job-engine'], (unlockUpdate) => { mutex.lock(['job-engine'], (unlockUpdate) => {
let postJob = () => { let postJob = () => {
this.processorsStatus[processorTag]['running'] = false; this.processorsStatus[processorTag]['running'] = false;
...@@ -162,7 +153,7 @@ class JobEngine { ...@@ -162,7 +153,7 @@ class JobEngine {
if (!unlocked) { if (!unlocked) {
unlock(); unlock();
} }
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true); this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), JobEngine.JOB_WAIT_TIME, false, true);
}; };
this.jobRepository this.jobRepository
...@@ -178,10 +169,17 @@ class JobEngine { ...@@ -178,10 +169,17 @@ class JobEngine {
}); });
} }
else { else {
return Promise.reject('job_not_found');
}
})
.then(() => {
this.processorsStatus[processorTag]['running'] = false; this.processorsStatus[processorTag]['running'] = false;
unlock();
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true); this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), 500, false, true);
} })
.catch(() => {
this.processorsStatus[processorTag]['running'] = false;
unlock();
this.running && task.scheduleTask(processorTag, this._getTask.bind(this, processorTag, processorID), JobEngine.JOB_WAIT_TIME, false, true);
}); });
}); });
} }
......
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