Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature - rework comms utils / add fluxd zmq #1361

Draft
wants to merge 16 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ZelBack/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = {
rpcport: 16124,
porttestnet: 26125,
rpcporttestnet: 26124,
zmqport: 28332,
},
minimumFluxBenchAllowedVersion: '4.0.0',
minimumFluxOSAllowedVersion: '5.4.0',
Expand Down
9 changes: 3 additions & 6 deletions ZelBack/src/services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11817,8 +11817,7 @@ async function checkMyAppsAvailability() {
throw err.message;
});
await serviceHelper.delay(10 * 1000);
// eslint-disable-next-line no-await-in-loop
let askingIP = await fluxNetworkHelper.getRandomConnection();
let askingIP = fluxNetworkHelper.getRandomConnection();
if (!askingIP) {
checkMyAppsAvailability();
return;
Expand Down Expand Up @@ -11993,11 +11992,9 @@ async function checkInstallingAppPortAvailable(portsToTest = []) {
});
}
await serviceHelper.delay(10 * 1000);
// eslint-disable-next-line no-await-in-loop
let askingIP = await fluxNetworkHelper.getRandomConnection();
let askingIP = fluxNetworkHelper.getRandomConnection();
while (!askingIP || askingIP.split(':')[0] === myIP) {
// eslint-disable-next-line no-await-in-loop
askingIP = await fluxNetworkHelper.getRandomConnection();
askingIP = fluxNetworkHelper.getRandomConnection();
}
let askingIpPort = config.server.apiport;
if (askingIP.includes(':')) { // has port specification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ async function startFluxNode(req, res) {
async function viewDeterministicFluxNodeList(req, res) {
let { filter } = req.params;
filter = filter || req.query.filter;
const useCache = req.params.useCache ?? true;

const rpccall = 'viewdeterministiczelnodelist'; // viewdeterministicfluxnodelist
const rpcparameters = [];
if (filter) {
rpcparameters.push(filter);
}

response = await daemonServiceUtils.executeCall(rpccall, rpcparameters);
response = await daemonServiceUtils.executeCall(rpccall, rpcparameters, { useCache });

return res ? res.json(response) : response;
}
Expand Down
10 changes: 6 additions & 4 deletions ZelBack/src/services/daemonService/daemonServiceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ let daemonCallRunning = false;
* @param {string[]} params RPC parameters.
* @returns {object} Message.
*/
async function executeCall(rpc, params) {
async function executeCall(rpc, params, options = {}) {
const useCache = options.useCache ?? true;

const rpcparameters = params || [];
try {
let data;
Expand Down Expand Up @@ -71,11 +73,11 @@ async function executeCall(rpc, params) {
const randomDelay = Math.floor((Math.random() * 25)) + 10;
await serviceHelper.delay(randomDelay);
}
if (rpc === 'getBlock') {
if (useCache && rpc === 'getBlock') {
data = blockCache.get(rpc + serviceHelper.ensureString(rpcparameters));
} else if (rpc === 'getRawTransaction') {
} else if (useCache && rpc === 'getRawTransaction') {
data = rawTxCache.get(rpc + serviceHelper.ensureString(rpcparameters));
} else {
} else if (useCache) {
data = cache.get(rpc + serviceHelper.ensureString(rpcparameters));
}
if (!data) {
Expand Down
4 changes: 2 additions & 2 deletions ZelBack/src/services/enterpriseNodesService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const config = require('config');
const fluxCommunicationUtils = require('./fluxCommunicationUtils');
const networkStateService = require('./networkStateService');
const messageHelper = require('./messageHelper');
const dbHelper = require('./dbHelper');
const log = require('../lib/log');
Expand All @@ -12,7 +12,7 @@ const globalAppsInformation = config.database.appsglobal.collections.appsInforma
*/
async function getEnterpriseList() {
try {
const nodeList = await fluxCommunicationUtils.deterministicFluxList();
const nodeList = networkStateService.networkState();
const enterpriseList = []; // txhash, outidx, pubkey, score, ip, payment_address?, tier,
// user collateralization, 200k in flux nodes is most trusted, get 500 points
// 200k flux in nodes, is most trusted, 5 * 40, 200 * 1, get 500 points
Expand Down
Loading
Loading