Merge pull request #2175 from Luis-Fernando-Molina/develop

Contribution: Network: Code comments and some fixes
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-10-20 06:17:29 -04:00
commit b016173231
22 files changed
+89 -94

No files matched your search

+4 -6
View File
@@ -8,16 +8,14 @@ exports.newDesktopApp = function newDesktopApp() {
async function run() {
/*
Heree we will store our running objects:
Here we will store our running objects:
*/
DK.running = {}
/*
This is the Web Sockets client that interacts with the Superalgos Network.
This is the Personal Social Graph for the user running this App.
*/
DK.running.socialGraph = DK.projects.socialTrading.modules.socialGraph.newSocialTradingModulesSocialGraph()
await DK.running.socialGraph.initialize()
/*
This is the Web Sockets client that interacts with the Superalgos Network.
*/
@@ -25,11 +23,11 @@ exports.newDesktopApp = function newDesktopApp() {
await DK.running.webSocketsClient.initialize()
console.log('Desktop Client Connected to Network Node via Web Sockets ................... Connected to port ' + global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT)
/* These are the Network Interfaces by which the UI interacts with the Desktop App.*/
/* These are the Network Interfaces by which the Web App interacts with this Desktop Client.*/
DK.running.webSocketsInterface = DK.projects.socialTrading.modules.webSocketsInterface.newDesktopModulesWebSocketsInterface()
DK.running.webSocketsInterface.initialize()
console.log('Desktop Client Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
console.log('Desktop Client Web Sockets Interface ....................................... Listening at port ' + global.env.DESKTOP_WEB_SOCKETS_INTERFACE_PORT)
DK.running.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface()
+1 -1
View File
@@ -22,7 +22,7 @@ exports.newDesktopRoot = function newDesktopRoot() {
*/
global.SA = {}
/* Load Environment Variables */
let ENVIRONMENT = require('./EnvironmentForDebug.js');
let ENVIRONMENT = require('./Environment.js');
let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment()
global.env = ENVIRONMENT_MODULE
/*
+8 -3
View File
@@ -10,14 +10,19 @@ exports.newEnvironment = function () {
let thisObject = {
BASE_PATH: basePath,
WEB_SERVER_URL: 'localhost',
CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041,
CLIENT_HTTP_INTERFACE_PORT: 34248,
PLATFORM_WEB_SOCKETS_INTERFACE_PORT: 18041,
NETWORK_WEB_SOCKETS_INTERFACE_PORT: 18042,
DESKTOP_WEB_SOCKETS_INTERFACE_PORT: 18043,
DESKTOP_WEB_SOCKETS_INTERFACE_HOST: 'localhost',
PLATFORM_HTTP_INTERFACE_PORT: 34248,
DESKTOP_HTTP_INTERFACE_PORT: 34249,
PATH_TO_DATA_STORAGE: path.join(basePath, './Platform/My-Data-Storage'),
PATH_TO_PROJECTS: path.join(basePath, './Projects'),
PATH_TO_LOG_FILES: path.join(basePath, './Platform/My-Log-Files'),
PATH_TO_PROJECTS_REQUIRED: path.join(basePath, './Projects'),
PATH_TO_PROJECT_SCHEMA: path.join(basePath, './Projects/ProjectsSchema.json'),
PATH_TO_CLIENT: path.join(basePath, './Platform'),
PATH_TO_PLATFORM: path.join(basePath, './Platform'),
PATH_TO_DESKTOP: './Desktop',
PATH_TO_DEFAULT_WORKSPACE: path.join(basePath, './Projects/Foundations/Plugins/Workspaces'),
PATH_TO_MY_WORKSPACES: path.join(basePath, './Platform/My-Workspaces'),
PATH_TO_FONTS: path.join(basePath, './Platform/WebServer/Fonts')
-24
View File
@@ -1,24 +0,0 @@
exports.newEnvironment = function () {
let thisObject = {
WEB_SERVER_URL: 'localhost',
CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041,
NETWORK_WEB_SOCKETS_INTERFACE_PORT: 18042,
DESKTOP_WEB_SOCKETS_INTERFACE_PORT: 18043,
DESKTOP_WEB_SOCKETS_INTERFACE_HOST: 'localhost',
CLIENT_HTTP_INTERFACE_PORT: 34248,
DESKTOP_HTTP_INTERFACE_PORT: 34249,
PATH_TO_DATA_STORAGE: './Platform/My-Data-Storage',
PATH_TO_LOG_FILES: './Platform/My-Log-Files',
PATH_TO_PROJECTS: './Projects',
PATH_TO_PROJECTS_REQUIRED: './Projects',
PATH_TO_PROJECT_SCHEMA: './Projects/ProjectsSchema.json',
PATH_TO_CLIENT: './Platform',
PATH_TO_DESKTOP: './Desktop',
PATH_TO_DEFAULT_WORKSPACE: './Projects/Foundations/Plugins/Workspaces',
PATH_TO_MY_WORKSPACES: './Platform/My-Workspaces',
PATH_TO_FONTS: './Platform/WebServer/Fonts'
}
return thisObject
}
-14
View File
@@ -1,14 +0,0 @@
{
"folders": [
{
"path": "C:\\Superalgos\\Network"
},
{
"path": "C:\\Superalgos\\Projects\\Network"
},
{
"path": "C:\\Superalgos\\Projects\\Social-Trading"
}
],
"settings": {}
}
-17
View File
@@ -1,17 +0,0 @@
{
"files.exclude": {
"**/Data-Storage": true,
"**/Documentation": true,
"**/Log-Files": true,
"**/node_modules": true,
"**/Deprecated-Code": true
},
"search.exclude": {
"**/Data-Storage": true,
"**/Documentation": true,
"**/Log-Files": true,
"**/node_modules": true,
"**/Deprecated-Code": true
},
"search.maintainFileSearchCache": true
}
+7 -3
View File
@@ -10,14 +10,18 @@ exports.newNetworkNode = function newNetworkNode() {
async function run() {
/*
Let's start the Network Interfaces
Other Network Nodes and Client Apps will communicate with this Network Node via it's Websocket Interface.
*/
NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface()
NT.webSocketsInterface.initialize()
/*
The Social Graph Service is the first and for now, the only service this Network Node provides.
*/
thisObject.socialGraphService = NT.projects.socialTrading.modules.socialGraph.newNetworkModulesSocialGraph()
await thisObject.socialGraphService.initialize()
/*
The Sotrage deals with persisting the Social Graph.
*/
thisObject.storage = NT.projects.socialTrading.modules.storage.newSocialTradingModulesStorage()
thisObject.storage.initialize()
}
+1 -1
View File
@@ -22,7 +22,7 @@ exports.newNetworkRoot = function newNetworkRoot() {
*/
global.SA = {}
/* Load Environment Variables */
let ENVIRONMENT = require('./EnvironmentForDebug.js');
let ENVIRONMENT = require('./Environment.js');
let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment()
global.env = ENVIRONMENT_MODULE
/*
+10 -10
View File
@@ -24,7 +24,7 @@ exports.newHttpInterface = function newHttpInterface() {
/*
We will create an HTTP Server and leave it running forever.
*/
SA.nodeModules.http.createServer(onHttpRequest).listen(global.env.CLIENT_HTTP_INTERFACE_PORT)
SA.nodeModules.http.createServer(onHttpRequest).listen(global.env.PLATFORM_HTTP_INTERFACE_PORT)
/* Starting the browser now is optional */
if (process.argv.includes("noBrowser")) {
//Running Client only with no UI.
@@ -33,7 +33,7 @@ exports.newHttpInterface = function newHttpInterface() {
if (initialWorkspace.name !== undefined) {
queryString = '/?initialWorkspaceName=' + initialWorkspace.name + '&initialWorkspaceProject=' + initialWorkspace.project + '&initialWorkspaceType=' + initialWorkspace.type
}
SA.nodeModules.open('http://localhost:' + global.env.CLIENT_HTTP_INTERFACE_PORT + queryString)
SA.nodeModules.open('http://localhost:' + global.env.PLATFORM_HTTP_INTERFACE_PORT + queryString)
}
}
@@ -1311,17 +1311,17 @@ exports.newHttpInterface = function newHttpInterface() {
break
case 'LegacyPlotter.js':
{
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_CLIENT + '/WebServer/LegacyPlotter.js', httpResponse)
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_PLATFORM + '/WebServer/LegacyPlotter.js', httpResponse)
}
break
case 'PlotterPanel.js':
{
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_CLIENT + '/WebServer/PlotterPanel.js', httpResponse)
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_PLATFORM + '/WebServer/PlotterPanel.js', httpResponse)
}
break
case 'Images': // This means the Images folder.
{
let path = global.env.PATH_TO_CLIENT + '/WebServer/Images/' + requestPath[2]
let path = global.env.PATH_TO_PLATFORM + '/WebServer/Images/' + requestPath[2]
if (requestPath[3] !== undefined) {
path = path + '/' + requestPath[3]
@@ -1403,12 +1403,12 @@ exports.newHttpInterface = function newHttpInterface() {
break
case 'WebServer': // This means the WebServer folder.
{
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_CLIENT + '/WebServer/' + requestPath[2], httpResponse)
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_PLATFORM + '/WebServer/' + requestPath[2], httpResponse)
}
break
case 'externalScripts': // This means the WebServer folder.
{
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_CLIENT + '/WebServer/externalScripts/' + requestPath[2], httpResponse)
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_PLATFORM + '/WebServer/externalScripts/' + requestPath[2], httpResponse)
}
break
case 'Plotters': // This means the plotter folder, not to be confused with the Plotters script!
@@ -1423,12 +1423,12 @@ exports.newHttpInterface = function newHttpInterface() {
break
case 'ChartLayers':
{
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_CLIENT + '/UI/' + endpointOrFile + '/' + requestPath[2], httpResponse)
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_PLATFORM + '/UI/' + endpointOrFile + '/' + requestPath[2], httpResponse)
}
break
case 'Files':
{
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_CLIENT + '/UI/Data-Files/' + requestPath[2], httpResponse)
SA.projects.foundations.utilities.httpResponses.respondWithFile(global.env.PATH_TO_PLATFORM + '/UI/Data-Files/' + requestPath[2], httpResponse)
}
break
case 'Fonts':
@@ -1943,7 +1943,7 @@ exports.newHttpInterface = function newHttpInterface() {
break
default:
{
SA.projects.foundations.utilities.httpResponses.respondWithWebFile(httpResponse, endpointOrFile, global.env.PATH_TO_CLIENT)
SA.projects.foundations.utilities.httpResponses.respondWithWebFile(httpResponse, endpointOrFile, global.env.PATH_TO_PLATFORM)
}
}
} catch (err) {
+1 -1
View File
@@ -9,7 +9,7 @@
const WEB_SOCKET = SA.nodeModules.ws
let socketServer
let port = global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT
let port = global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT
return thisObject
+2 -2
View File
@@ -135,11 +135,11 @@ exports.newPlatformApp = function newPlatformApp() {
console.log('')
WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface()
WEB_SOCKETS_INTERFACE.initialize()
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT)
HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface()
HTTP_INTERFACE.initialize(initialWorkspace)
console.log('Http Interface .............................................. Listening at port ' + global.env.CLIENT_HTTP_INTERFACE_PORT)
console.log('Http Interface .............................................. Listening at port ' + global.env.PLATFORM_HTTP_INTERFACE_PORT)
console.log('')
console.log("You are running Superalgos Beta 12")
@@ -90,7 +90,7 @@ exports.newDataMiningBotModulesCheckWebhook = function (processIndex) {
try {
let http = SA.nodeModules.http
let url = 'http://' + global.env.WEB_SERVER_URL +
':' + global.env.CLIENT_HTTP_INTERFACE_PORT +
':' + global.env.PLATFORM_HTTP_INTERFACE_PORT +
'/Webhook/Fetch-Messages/' +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" +
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" +
@@ -24,7 +24,7 @@
host = 'localhost'
}
if (port === undefined) {
port = global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT
port = global.env.PLATFORM_WEB_SOCKETS_INTERFACE_PORT
}
let messageCounter = 0
@@ -1,5 +1,16 @@
exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSocketsInterface() {
/*
This module represents the websockets interface of the Network Node.
A Network Nodes is epected to receive conections request from 2 different types
of entities:
1. Other Network Nodes.
2. Clients / Apps.
This module deals with those 2 connection types and is the one receiving from
and sending messages to those entities.
*/
let thisObject = {
networkClients: undefined,
networkPeers: undefined,
@@ -45,7 +56,6 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
socketServer.on('connection', onConnectionOpened)
function onConnectionOpened(socket)
/*
This function is executed every time a new Websockets connection
is stablished.
@@ -4,8 +4,14 @@ exports.newSocialTradingModulesSocialGraph = function newSocialTradingModulesSoc
the user profile of the user of the Desktop App. A personal social
graph is very similar to the one mantained at a Netwrok Node,
the mainn difference is that it only includes information relevant
to this particular user, and not for al the users in the system
to this particular user, and not for all Superalgos users
as in the Network Node.
Why we need this?
Because we need to minimize the calls to the network. There might be
information that the web app needs that we already have, so there is
no need to ask it to a network node.
*/
let thisObject = {
initialize: initialize,
@@ -45,7 +45,7 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock
webApp = {
socket: socket
}
console.log('Desktop Web App Connected to Web Sockets Interface ......................... Connected to port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
console.log('Desktop Web App Connected to Web Sockets Interface ......................... Connected to port ' + global.env.DESKTOP_WEB_SOCKETS_INTERFACE_PORT)
webApp.socket.on('close', onConnectionClosed)
webApp.socket.on('message', onMenssage)
@@ -92,7 +92,7 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock
function onConnectionClosed() {
webApp = undefined
console.log('Desktop Web App Discoonnected from Web Sockets Interface ................... Disonnected from port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
console.log('Desktop Web App Discoonnected from Web Sockets Interface ................... Disonnected from port ' + global.env.DESKTOP_WEB_SOCKETS_INTERFACE_PORT)
}
} catch (err) {
@@ -3,6 +3,13 @@ exports.newBootstrap = function newBootstrap() {
This module helps the Network Node to bootstrap, by
loading all the services and data that needs to start
operating.
In particular, a network node operates with all User Profiles loaded in
memory maps. These profiles become part of the system in the form of User Profiles
Plugins at the Governance System, when user submit them. This means
that all these profiles are already at the local disk of the Network Node.
From there they will be loaded into memory as part of this bootstrapping process.
*/
let thisObject = {
/* Framework Functions */
@@ -6,6 +6,10 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
* Send an Event that happened at the Network Client to the Network.
* Make a Query to the Network Node for info needed at the Network Client.
This interface is one layer above the communication protocol interface
where actual messages are received through, like for instance the
websockets interface.
*/
let thisObject = {
messageReceived: messageReceived,
@@ -1,5 +1,12 @@
exports.newSocialTradingModulesPeerInterface = function newSocialTradingModulesPeerInterface() {
/*
This module represents the Interface the Network Node have
with other Network Nodes connected to it.
This interface is one layer above the communication protocol interface
where actual messages are received through, like for instance the
websockets interface.
*/
let thisObject = {
initialize: initialize,
finalize: finalize,
@@ -17,6 +24,6 @@ exports.newSocialTradingModulesPeerInterface = function newSocialTradingModulesP
}
function run() {
}
}
}
@@ -1,7 +1,7 @@
exports.newNetworkModulesSocialGraph = function newNetworkModulesSocialGraph() {
/*
This module represents the Social Graph Service that
this deals with the Social Graph this node mantains.
deals with the Social Graph this node mantains.
The Social Graph is one of the services the Network Node provides.
This service is responsible for mantaining the whole Social Graph
@@ -3,6 +3,15 @@ exports.newSocialTradingModulesStorage = function newSocialTradingModulesStorage
This module represents the Network Node Physical Storage.
It is used to save the in-memory events and also to load
them when the node is starting.
Each node has a github repository to store its social graph.
That Github repository can be used by any other node to get the history of
events that can build the social graph.
Each Network Node saves locally all unsaved events, every one minute,
and after saving, pushes the changes to it's Github repo, which
acts as a backup of itself, and also for other new nodes to bootstrap
their own copy of the social graph.
*/
let thisObject = {
initialize: initialize,
+2 -2
View File
@@ -1,11 +1,11 @@
/*
The Superalgos Desktop is one of the 3 clients of the Superalgos Network:
The Superalgos Desktop is one of the 3 clients of the Superalgos P2P Network:
* Superalgos Mobile
* Superalgos Desktop
* Superalgos Server
Users can unse any of these clients for their social trading activities.
Users can use any of these clients for their social trading activities.
This module represents the Nodejs command that users have to start the Desktop App..