Fixed: price storeHistory
- price.storeHistory interval will trigger only when node is master
This commit is contained in:
parent
54470b42d7
commit
fb9ac8080b
@ -662,6 +662,7 @@ periodicProcess.start = function() {
|
|||||||
periodicProcess.stop();
|
periodicProcess.stop();
|
||||||
periodicProcess();
|
periodicProcess();
|
||||||
assetList.forEach(asset => coupling.initiate(asset));
|
assetList.forEach(asset => coupling.initiate(asset));
|
||||||
|
coupling.price.storeHistory.start();
|
||||||
periodicProcess.instance = setInterval(periodicProcess, PERIOD_INTERVAL);
|
periodicProcess.instance = setInterval(periodicProcess, PERIOD_INTERVAL);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -671,6 +672,7 @@ periodicProcess.stop = function() {
|
|||||||
delete periodicProcess.instance;
|
delete periodicProcess.instance;
|
||||||
}
|
}
|
||||||
coupling.stopAll();
|
coupling.stopAll();
|
||||||
|
coupling.price.storeHistory.stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
function blockchainReCheck() {
|
function blockchainReCheck() {
|
||||||
|
|||||||
20
src/price.js
20
src/price.js
@ -25,10 +25,21 @@ function storeHistory(asset, rate) {
|
|||||||
DB.query("INSERT INTO PriceHistory (asset, rate) VALUE (?, ?)", [asset, rate.toFixed(8)])
|
DB.query("INSERT INTO PriceHistory (asset, rate) VALUE (?, ?)", [asset, rate.toFixed(8)])
|
||||||
.then(_ => null).catch(error => console.error(error))
|
.then(_ => null).catch(error => console.error(error))
|
||||||
}
|
}
|
||||||
setInterval(() => {
|
|
||||||
for (let asset in currentRate)
|
storeHistory.start = function() {
|
||||||
storeHistory(asset, currentRate[asset]);
|
storeHistory.stop();
|
||||||
}, REC_HISTORY_INTERVAL);
|
storeHistory.instance = setInterval(() => {
|
||||||
|
for (let asset in currentRate)
|
||||||
|
storeHistory(asset, currentRate[asset]);
|
||||||
|
}, REC_HISTORY_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
storeHistory.stop = function() {
|
||||||
|
if (storeHistory.instance !== undefined) {
|
||||||
|
clearInterval(storeHistory.instance);
|
||||||
|
delete storeHistory.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getPastRate(asset, hrs = 24) {
|
function getPastRate(asset, hrs = 24) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -196,6 +207,7 @@ function checkForRatedSellers(asset) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
getRates,
|
getRates,
|
||||||
getHistory,
|
getHistory,
|
||||||
|
storeHistory,
|
||||||
updateLastTime,
|
updateLastTime,
|
||||||
MIN_TIME,
|
MIN_TIME,
|
||||||
noOrder(asset, buy, sell) {
|
noOrder(asset, buy, sell) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user