- Promisified the refresher invoke fn.
- Connect to next node upon 1st refresher resolve
This commit is contained in:
sairajzero 2021-07-24 01:04:20 +05:30
parent e565658bb0
commit a91df8a2b2
2 changed files with 22 additions and 12 deletions

View File

@ -525,7 +525,7 @@ function deleteMigratedData(old_sn, vectorClock, receiverID, from, packet) {
}; };
function initiateRefresh() { function initiateRefresh() {
refresher.invoke(false); refresher.invoke(false).then(_ => null).catch(_ => null);
}; };
//Forward incoming to next node //Forward incoming to next node
@ -682,6 +682,7 @@ dataMigration.intimateAllNodes = function() {
//-----EXPORTS----- //-----EXPORTS-----
module.exports = { module.exports = {
reconnectNextNode,
processTaskFromSupernode, processTaskFromSupernode,
forwardToNextNode, forwardToNextNode,
dataMigration, dataMigration,

View File

@ -34,7 +34,8 @@ function startNode() {
floGlobals.appList = base.appList; floGlobals.appList = base.appList;
floGlobals.appSubAdmins = base.appSubAdmins; floGlobals.appSubAdmins = base.appSubAdmins;
refreshData.base = base; refreshData.base = base;
refreshData.invoke(); refreshData.invoke()
.then(_ => intra.reconnectNextNode()).catch(_ => null)
//Start Server //Start Server
const server = new Server(config["port"], client, intra); const server = new Server(config["port"], client, intra);
server.refresher = refreshData; server.refresher = refreshData;
@ -57,20 +58,28 @@ const refreshData = {
count: null, count: null,
base: null, base: null,
invoke(flag = true) { invoke(flag = true) {
this.count = floGlobals.sn_config.refreshDelay; return new Promise((resolve, reject) => {
console.info("Refresher processor has started at " + Date()); this.count = floGlobals.sn_config.refreshDelay;
refreshBlockchainData(this.base, flag).then(result => { console.info("Refresher processor has started at " + Date());
console.log(result); refreshBlockchainData(this.base, flag).then(result => {
diskCleanUp(this.base) console.log(result);
.then(result => console.log(result)) diskCleanUp(this.base)
.catch(warn => console.warn(warn)) .then(result => console.log(result))
.finally(_ => console.info("Refresher processor has finished at " + Date())); .catch(warn => console.warn(warn))
}).catch(error => console.error(error)); .finally(_ => {
console.info("Refresher processor has finished at " + Date());
resolve(true);
});
}).catch(error => {
console.error(error);
reject(false);
});
});
}, },
get countdown() { get countdown() {
this.count--; this.count--;
if (this.count <= 0) if (this.count <= 0)
this.invoke(); this.invoke().then(_ => null).catch(_ => null);
} }
}; };