Splitting Memory and changing it to Network Project
This commit is contained in:
1 parent
5712193f72
commit
3345eff347
16 files changed
+86
-46
No files matched your search
+1
-4
@@ -1,12 +1,9 @@
|
||||
exports.newSocialTradingGlobalsMemory = function () {
|
||||
exports.newNetworkGlobalsMemory = function () {
|
||||
/*
|
||||
Here is the Data we are going to keep in memory.
|
||||
*/
|
||||
let thisObject = {
|
||||
maps: {
|
||||
USER_PROFILES_BY_ID: new Map(), // Here we will store the user profiles by User Profile Id.
|
||||
USER_PROFILES_BY_HANDLE: new Map(), // Here we will store the user profiles by User Profile Handle.
|
||||
USER_PROFILES_BY_BLOCHAIN_ACCOUNT: new Map(), // Here we will store the user profiles by Blockchain Account.
|
||||
EVENTS: new Map() // This is the registry of all events received that prevents processing them more than once.
|
||||
},
|
||||
arrays: {
|
||||
@@ -304,7 +304,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
|
||||
/*
|
||||
The signature gives us the blockchain account, and the account the user profile.
|
||||
*/
|
||||
let witnessUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.get(caller.blockchainAccount)
|
||||
let witnessUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.get(caller.blockchainAccount)
|
||||
|
||||
if (witnessUserProfile === undefined) {
|
||||
let response = {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
exports.newNetworkGlobalsMemory = function () {
|
||||
/*
|
||||
Here is the Data we are going to keep in memory.
|
||||
*/
|
||||
let thisObject = {
|
||||
maps: {
|
||||
USER_PROFILES_BY_ID: new Map(), // Here we will store the user profiles by User Profile Id.
|
||||
USER_PROFILES_BY_HANDLE: new Map(), // Here we will store the user profiles by User Profile Handle.
|
||||
USER_PROFILES_BY_BLOCHAIN_ACCOUNT: new Map() // Here we will store the user profiles by Blockchain Account.
|
||||
},
|
||||
arrays: {
|
||||
}
|
||||
}
|
||||
|
||||
return thisObject
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
exports.newNetworkNetworkNodePicker = function newNetworkNetworkNodePicker () {
|
||||
let thisObject = {
|
||||
pickOneNetworkNode: pickOneNetworkNode
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function pickOneNetworkNode() {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,8 @@
|
||||
"name": "Load Save Frame",
|
||||
"propertyName": "loadSaveFrame",
|
||||
"functionName": "newVisualScriptingUtilitiesLoadSaveFrame"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Meshes",
|
||||
"propertyName": "meshes",
|
||||
"functionName": "newVisualScriptingUtilitiesMeshes"
|
||||
@@ -1350,7 +1351,14 @@
|
||||
"name": "Network",
|
||||
"propertyName": "network",
|
||||
"NT": {
|
||||
"globals": [],
|
||||
"globals": [
|
||||
{
|
||||
"name": "Memory",
|
||||
"propertyName": "memory",
|
||||
"functionName": "newNetworkGlobalsMemory",
|
||||
"fileName": "Memory.js"
|
||||
}
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"name": "Web Sockets Interface",
|
||||
@@ -1368,7 +1376,14 @@
|
||||
"utilities": []
|
||||
},
|
||||
"SA": {
|
||||
"globals": [],
|
||||
"globals": [
|
||||
{
|
||||
"name": "Memory",
|
||||
"propertyName": "memory",
|
||||
"functionName": "newNetworkGlobalsMemory",
|
||||
"fileName": "Memory.js"
|
||||
}
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"name": "Web Sockets App Client",
|
||||
@@ -1377,21 +1392,21 @@
|
||||
"fileName": "WebSocketsAppClient.js"
|
||||
}
|
||||
],
|
||||
"utilities": []
|
||||
"utilities": [
|
||||
{
|
||||
"name": "Network Node Picker",
|
||||
"propertyName": "networkNodePicker",
|
||||
"functionName": "newNetworkNetworkNodePicker",
|
||||
"fileName": "NetworkNodePicker.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Social-Trading",
|
||||
"propertyName": "socialTrading",
|
||||
"NT": {
|
||||
"globals": [
|
||||
{
|
||||
"name": "Memory",
|
||||
"propertyName": "memory",
|
||||
"functionName": "newSocialTradingGlobalsMemory",
|
||||
"fileName": "Memory.js"
|
||||
}
|
||||
],
|
||||
"globals": [],
|
||||
"modules": [
|
||||
{
|
||||
"name": "User Profiles",
|
||||
|
||||
@@ -56,9 +56,9 @@ exports.newBootstrap = function newBootstrap() {
|
||||
ranking
|
||||
)
|
||||
|
||||
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile)
|
||||
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile)
|
||||
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
|
||||
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile)
|
||||
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile)
|
||||
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
|
||||
/*
|
||||
Each User Profile might have Signing Accounts, meaning
|
||||
accounts that can be siging on behalf of the User Profile.
|
||||
@@ -70,7 +70,7 @@ exports.newBootstrap = function newBootstrap() {
|
||||
let signatureObject = config.signature
|
||||
let web3 = new SA.nodeModules.web3()
|
||||
let blockchainAccount = web3.eth.accounts.recover(signatureObject)
|
||||
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
|
||||
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
|
||||
We will not accept events that have already been processed.
|
||||
*/
|
||||
|
||||
if (NT.projects.socialTrading.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) {
|
||||
if (NT.projects.network.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) {
|
||||
let response = {
|
||||
result: 'Error',
|
||||
message: 'Client Interface Event Already Exists.'
|
||||
@@ -133,8 +133,8 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
|
||||
try {
|
||||
let event = NT.projects.socialTrading.modules.event.newSocialTradingModulesEvent()
|
||||
event.initialize(eventReceived)
|
||||
NT.projects.socialTrading.globals.memory.maps.EVENTS.set(eventReceived.eventId, event)
|
||||
NT.projects.socialTrading.globals.memory.arrays.EVENTS.push(event)
|
||||
NT.projects.network.globals.memory.maps.EVENTS.set(eventReceived.eventId, event)
|
||||
NT.projects.network.globals.memory.arrays.EVENTS.push(event)
|
||||
|
||||
let response = {
|
||||
result: 'Ok',
|
||||
|
||||
@@ -64,7 +64,7 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
|
||||
if (thisObject.emitterUserProfileId === undefined) {
|
||||
throw ('Emitter User Profile Id Not Provided.')
|
||||
}
|
||||
emitterUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.emitterUserProfileId)
|
||||
emitterUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.emitterUserProfileId)
|
||||
if (emitterUserProfile === undefined) {
|
||||
throw ('Emitter User Profile Not Found.')
|
||||
}
|
||||
@@ -72,7 +72,7 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
|
||||
Validate Target User Profile.
|
||||
*/
|
||||
if (thisObject.targetUserProfileId !== undefined) {
|
||||
targetUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId)
|
||||
targetUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId)
|
||||
if (targetUserProfile === undefined) {
|
||||
throw ('Target User Profile Not Found.')
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ exports.newSocialTradingModulesQueriesBotProfileStats = function newSocialTradin
|
||||
*/
|
||||
let userProfile
|
||||
if (queryReceived.targetUserProfileId !== undefined) {
|
||||
userProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
|
||||
userProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
|
||||
} else {
|
||||
userProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle)
|
||||
userProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle)
|
||||
}
|
||||
|
||||
if (userProfile === undefined) {
|
||||
|
||||
@@ -22,7 +22,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
|
||||
function initialize(queryReceived) {
|
||||
|
||||
NT.projects.socialTrading.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
|
||||
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, NT.projects.socialTrading.globals.memory.arrays.EVENTS)
|
||||
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, NT.projects.network.globals.memory.arrays.EVENTS)
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
|
||||
switch (thisObject.direction) {
|
||||
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
|
||||
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
|
||||
let event = NT.projects.socialTrading.globals.memory.arrays.EVENTS[i]
|
||||
let event = NT.projects.network.globals.memory.arrays.EVENTS[i]
|
||||
if (event === undefined) { break }
|
||||
checkEventContext(event)
|
||||
}
|
||||
@@ -39,7 +39,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
|
||||
}
|
||||
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
|
||||
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
|
||||
let event = NT.projects.socialTrading.globals.memory.arrays.EVENTS[i]
|
||||
let event = NT.projects.network.globals.memory.arrays.EVENTS[i]
|
||||
if (event === undefined) { break }
|
||||
checkEventContext(event)
|
||||
}
|
||||
@@ -59,11 +59,11 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
|
||||
|
||||
Any of the above happening, means that indeed it is related.
|
||||
*/
|
||||
let emitterUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(event.emitterUserProfileId)
|
||||
let emitterUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(event.emitterUserProfileId)
|
||||
let emitterBotProfile = emitterUserProfile.bots.get(event.emitterBotProfileId)
|
||||
let emitterPost = emitterUserProfile.posts.get(event.emitterPostHash)
|
||||
|
||||
let targetUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(event.targetUserProfileId)
|
||||
let targetUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(event.targetUserProfileId)
|
||||
let targetBotProfile
|
||||
let targetPost
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ exports.newSocialTradingModulesQueriesUnfollowedUserProfiles = function newSocia
|
||||
|
||||
function initialize(queryReceived) {
|
||||
|
||||
thisObject.emitterUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.emitterUserProfileId)
|
||||
thisObject.emitterUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.emitterUserProfileId)
|
||||
if (thisObject.emitterUserProfile === undefined) {
|
||||
throw ('Emitter User Profile Not Found.')
|
||||
}
|
||||
|
||||
thisObject.profiles = Array.from(
|
||||
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID,
|
||||
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID,
|
||||
x => x[1]
|
||||
)
|
||||
thisObject.profiles.sort((a, b) => (a["ranking"] > b["ranking"]) ? 1 : -1)
|
||||
|
||||
@@ -18,9 +18,9 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
|
||||
Validate User Profile
|
||||
*/
|
||||
if (queryReceived.targetUserProfileId !== undefined) {
|
||||
thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
|
||||
thisObject.profile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
|
||||
} else {
|
||||
thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle)
|
||||
thisObject.profile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle)
|
||||
}
|
||||
|
||||
if (thisObject.profile === undefined) {
|
||||
|
||||
@@ -23,7 +23,7 @@ exports.newSocialTradingModulesQueriesUserProfiles = function newSocialTradingMo
|
||||
function initialize(queryReceived) {
|
||||
|
||||
thisObject.profiles = Array.from(
|
||||
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID,
|
||||
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID,
|
||||
x => x[1]
|
||||
)
|
||||
thisObject.profiles.sort((a, b) => (a["ranking"] > b["ranking"]) ? 1 : -1)
|
||||
|
||||
@@ -99,7 +99,7 @@ exports.newSocialTradingModulesSocialGraphPost = function newSocialTradingModule
|
||||
/*
|
||||
Validate Target User Profile.
|
||||
*/
|
||||
let targetUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId)
|
||||
let targetUserProfile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId)
|
||||
if (targetUserProfile === undefined) {
|
||||
throw ('Target User Profile Not Found.')
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ exports.newSocialTradingModulesStorage = function newSocialTradingModulesStorage
|
||||
try {
|
||||
let event = NT.projects.socialTrading.modules.event.newSocialTradingModulesEvent()
|
||||
event.initialize(storedEvent)
|
||||
NT.projects.socialTrading.globals.memory.maps.EVENTS.set(storedEvent.eventId, event)
|
||||
NT.projects.socialTrading.globals.memory.arrays.EVENTS.push(event)
|
||||
indexLastSavedEvent = NT.projects.socialTrading.globals.memory.arrays.EVENTS.length - 1
|
||||
NT.projects.network.globals.memory.maps.EVENTS.set(storedEvent.eventId, event)
|
||||
NT.projects.network.globals.memory.arrays.EVENTS.push(event)
|
||||
indexLastSavedEvent = NT.projects.network.globals.memory.arrays.EVENTS.length - 1
|
||||
} catch (err) {
|
||||
if (err.stack !== undefined) {
|
||||
console.log('[ERROR] Client Interface -> err.stack = ' + err.stack)
|
||||
@@ -94,8 +94,8 @@ exports.newSocialTradingModulesStorage = function newSocialTradingModulesStorage
|
||||
let eventsToSave = []
|
||||
let minuteToSave
|
||||
|
||||
for (let i = indexLastSavedEvent + 1; i < NT.projects.socialTrading.globals.memory.arrays.EVENTS.length; i++) {
|
||||
let event = NT.projects.socialTrading.globals.memory.arrays.EVENTS[i]
|
||||
for (let i = indexLastSavedEvent + 1; i < NT.projects.network.globals.memory.arrays.EVENTS.length; i++) {
|
||||
let event = NT.projects.network.globals.memory.arrays.EVENTS[i]
|
||||
|
||||
let currentMinute = Math.trunc((new Date()).valueOf() / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS)
|
||||
let eventMinute = Math.trunc(event.timestamp / SA.projects.foundations.globals.timeConstants.ONE_MIN_IN_MILISECONDS)
|
||||
|
||||
@@ -15,14 +15,14 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU
|
||||
Validate User Profile
|
||||
*/
|
||||
if (queryReceived.emitterUserProfileId !== undefined) {
|
||||
thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.emitterUserProfileId)
|
||||
thisObject.profile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.emitterUserProfileId)
|
||||
if (thisObject.profile === undefined) {
|
||||
throw ('Emitter User Profile Not Found.')
|
||||
}
|
||||
}
|
||||
|
||||
if (queryReceived.targetUserProfileId !== undefined) {
|
||||
thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
|
||||
thisObject.profile = SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
|
||||
if (thisObject.profile === undefined) {
|
||||
throw ('Target User Profile Not Found.')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user