-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from zelcash/development
v0.66.0
- Loading branch information
Showing
15 changed files
with
289 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const config = require('config'); | ||
const log = require('../lib/log'); | ||
|
||
const serviceHelper = require('./serviceHelper'); | ||
const explorerService = require('./explorerService'); | ||
const zelfluxCommunication = require('./zelfluxCommunication'); | ||
const zelappsService = require('./zelappsService'); | ||
|
||
async function startFluxFunctions() { | ||
try { | ||
log.info('Initiating MongoDB connection'); | ||
await serviceHelper.initiateDB(); // either true or throws error | ||
log.info('DB connected'); | ||
log.info('Preparing local database...'); | ||
const db = serviceHelper.databaseConnection(); | ||
const database = db.db(config.database.local.database); | ||
await serviceHelper.dropCollection(database, config.database.local.collections.activeLoginPhrases).catch((error) => { | ||
if (error.message !== 'ns not found') { | ||
log.error(error); | ||
} | ||
}); | ||
await serviceHelper.dropCollection(database, config.database.local.collections.activeSignatures).catch((error) => { | ||
if (error.message !== 'ns not found') { | ||
log.error(error); | ||
} | ||
}); | ||
await database.collection(config.database.local.collections.activeLoginPhrases).createIndex({ createdAt: 1 }, { expireAfterSeconds: 900 }); | ||
await database.collection(config.database.local.collections.activeSignatures).createIndex({ createdAt: 1 }, { expireAfterSeconds: 900 }); | ||
log.info('Local database prepared'); | ||
log.info('Preparing temporary database...'); | ||
// no need to drop temporary messages | ||
const databaseTemp = db.db(config.database.zelappsglobal.database); | ||
await databaseTemp.collection(config.database.zelappsglobal.collections.zelappsTemporaryMessages).createIndex({ receivedAt: 1 }, { expireAfterSeconds: 3600 }); | ||
log.info('Temporary database prepared'); | ||
zelfluxCommunication.adjustFirewall(); | ||
zelfluxCommunication.fluxDisovery(); | ||
log.info('Flux Discovery started'); | ||
zelfluxCommunication.keepConnectionsAlive(); | ||
zelfluxCommunication.keepIncomingConnectionsAlive(); | ||
zelfluxCommunication.checkDeterministicNodesCollisions(); | ||
setInterval(() => { | ||
zelfluxCommunication.checkDeterministicNodesCollisions(); | ||
}, 60000); | ||
log.info('Flux checks operational'); | ||
explorerService.initiateBlockProcessor(true, true); | ||
setInterval(() => { // every 8 mins (4 blocks) | ||
zelappsService.continuousZelAppHashesCheck(); | ||
}, 8 * 60 * 1000); | ||
log.info('Flux Block Processing Service started'); | ||
} catch (e) { | ||
log.error(e); | ||
setTimeout(() => { | ||
startFluxFunctions(); | ||
}, 15000); | ||
} | ||
} | ||
|
||
module.exports = { | ||
startFluxFunctions, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.