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

update millix-node v1.11.3

parent c0d769d5
......@@ -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.11.2</small>
millix node <small>v1.11.3</small>
<br>
</h1>
......
......@@ -774,8 +774,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 = 1629213000;
export const NODE_MILLIX_VERSION = '1.11.2-tangled';
export const NODE_MILLIX_BUILD_DATE = 1629385375;
export const NODE_MILLIX_VERSION = '1.11.3-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;
......@@ -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_VERSION = 4;
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_MOST = 0.2;
export const PEER_ROTATION_MORE_THAN_ALL = 0.01;
......@@ -893,5 +894,6 @@ export default {
PEER_ROTATION_MORE_THAN_ALL,
PEER_ROTATION_CONFIG,
JOB_CONFIG_PATH,
JOB_CONFIG_VERSION
JOB_CONFIG_VERSION,
DEBUG_LOG_FILTER
};
......@@ -19,4 +19,6 @@ console.log = function() {
enabled && showLog && config.MODE_DEBUG && _consoleLog.apply(console, arguments);
};
config.DEBUG_LOG_FILTER.forEach(filter => console.addFilter(filter));
export default console;
......@@ -29,7 +29,13 @@ class Task {
});
}
else {
try {
task();
}
catch (e) {
this.debug && console.log(`[task] error running task ${taskName}: ${e}`);
}
if (!once) {
self.runningTask[taskName] = setTimeout(run, waitTime);
}
......
......@@ -225,7 +225,7 @@ export class WalletTransactionConsensus {
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({
cause : 'transaction_validation_max_depth',
transaction_id_fail: transactionID,
......
......@@ -108,4 +108,4 @@ db.initialize()
});
}
});
//millix v1.11.2-tangled
//millix v1.11.3-tangled
......@@ -19,6 +19,8 @@ import os from 'os';
class JobEngine {
static JOB_WAIT_TIME = 1000;
constructor() {
this.debug = false;
this.configJobEngine = null;
......@@ -93,21 +95,26 @@ class JobEngine {
this.debug && console.log(`[job-engine] running job ${job.job_id} : ${job.job_name}`);
let unlocked = false;
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(() => {
unlock();
unlocked = true;
// run job
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}`);
if (!module || !payload || !module[payload.function_name]) {
return Promise.reject('job_invalid');
}
let postJob = () => {
const timestampEnd = ntp.now();
const lastElapse = timestampEnd.getTime() - timestampBegin.getTime();
this.debug && console.log(`[job-engine] done ${payload.module}:${payload.function_name} - ${lastElapse} ms`);
return new Promise((resolve, reject) => {
mutex.lock(['job-engine'], (unlockUpdate) => {
this.jobRepository.updateJobProgressStatus(job.job_id, 0, {
last_date_end: timestampEnd,
......@@ -116,45 +123,29 @@ class JobEngine {
})
.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);
resolve();
})
.catch(() => {
this.processorsStatus[processorTag]['running'] = false;
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)
.catch(postJob);
}
else {
mutex.lock(['job-engine'], (unlockUpdate) => {
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);
});
});
return Promise.reject('job_not_supported');
}
})
.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) => {
let postJob = () => {
this.processorsStatus[processorTag]['running'] = false;
......@@ -162,7 +153,7 @@ class JobEngine {
if (!unlocked) {
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
......@@ -178,10 +169,17 @@ class JobEngine {
});
}
else {
return Promise.reject('job_not_found');
}
})
.then(() => {
this.processorsStatus[processorTag]['running'] = false;
unlock();
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