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();
|
||||
assetList.forEach(asset => coupling.initiate(asset));
|
||||
coupling.price.storeHistory.start();
|
||||
periodicProcess.instance = setInterval(periodicProcess, PERIOD_INTERVAL);
|
||||
};
|
||||
|
||||
@ -671,6 +672,7 @@ periodicProcess.stop = function() {
|
||||
delete periodicProcess.instance;
|
||||
}
|
||||
coupling.stopAll();
|
||||
coupling.price.storeHistory.stop();
|
||||
};
|
||||
|
||||
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)])
|
||||
.then(_ => null).catch(error => console.error(error))
|
||||
}
|
||||
setInterval(() => {
|
||||
for (let asset in currentRate)
|
||||
storeHistory(asset, currentRate[asset]);
|
||||
}, REC_HISTORY_INTERVAL);
|
||||
|
||||
storeHistory.start = function() {
|
||||
storeHistory.stop();
|
||||
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) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -196,6 +207,7 @@ function checkForRatedSellers(asset) {
|
||||
module.exports = {
|
||||
getRates,
|
||||
getHistory,
|
||||
storeHistory,
|
||||
updateLastTime,
|
||||
MIN_TIME,
|
||||
noOrder(asset, buy, sell) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user