Some refactoring and comments added to code

This commit is contained in:
Luis Fernando Molina committed 2021-12-05 10:36:41 +01:00
1 parent e620174fa1
commit 65a141da5c
10 files changed
+70 -49

No files matched your search

+17 -13
View File
@@ -88,7 +88,7 @@ exports.newTaskServer = function newTaskServer() {
async function bootingProcess() {
try {
initializeProjectDefinitionNode()
await setupNetwork()
await setupP2PNetwork()
setupTaskHeartbeats()
startProcesses()
@@ -114,7 +114,7 @@ exports.newTaskServer = function newTaskServer() {
}
}
async function setupNetwork() {
async function setupP2PNetwork() {
/*
If we received a App Server Reference Node and a Signing Account, then we will connect to the P2P Network
*/
@@ -127,37 +127,41 @@ exports.newTaskServer = function newTaskServer() {
}
TS.projects.foundations.globals.taskConstants.P2P_NETWORK = {}
/*
We set up ourselves as a Network Client.
We set up the object that will hold our p2p network client identity, meaning the identity we will present to the network.
*/
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClient = SA.projects.network.modules.p2pNetworkClient.newNetworkModulesP2PNetworkClient()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClient.initialize()
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClientIdentity = SA.projects.network.modules.p2pNetworkClientIdentity.newNetworkModulesP2PNetworkClientIdentity()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClientIdentity.initialize()
/*
We will read all user profiles plugins and get from there our network identity.
We will read all user profiles plugins, store them in memory and get from there our own network client identity.
*/
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.userProfiles = SA.projects.network.modules.userProfiles.newNetworkModulesUserProfiles()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.userProfiles.initialize(TS.projects.foundations.globals.taskConstants.TASK_NODE.taskServerAppReference.referenceParent.config.codeName, TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClient)
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.userProfiles.initialize(
TS.projects.foundations.globals.taskConstants.TASK_NODE.taskServerAppReference.referenceParent.config.codeName,
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClientIdentity
)
/*
We set up the P2P Network.
We set up the P2P Network, meaning the array of nodes we will be able to connect to.
*/
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetwork = SA.projects.network.modules.p2pNetwork.newNetworkModulesP2PNetwork()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetwork.initialize('Network Client')
/*
Set up the connections to network peers nodes. These connections will be used to consume signals.
In this context peers means network nodes with a similar ranking that our network client identity.
*/
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkPeers = SA.projects.network.modules.p2pNetworkPeers.newNetworkModulesP2PNetworkPeers()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkPeers.initialize(
'Network Client',
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClient,
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClientIdentity,
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetwork,
global.env.TASK_SERVER_APP_MAX_OUTGOING_PEERS
)
/*
Set up the connections to network head nodes. These connections will be used to send signals.
Set up the connections to network start nodes. These connections will be used to send signals.
*/
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkPeers = SA.projects.network.modules.p2pNetworkPeers.newNetworkModulesP2PNetworkHead()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkPeers.initialize(
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkStart = SA.projects.network.modules.p2pNetworkPeers.newNetworkModulesP2PNetworkStart()
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkStart.initialize(
'Network Client',
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClient,
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkClientIdentity,
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetwork,
global.env.TASK_SERVER_APP_MAX_OUTGOING_HEADS
)