Review refactor

pull/296/head
Beaudan 6 years ago
parent d5546b9473
commit 0948a344d2

@ -5,7 +5,6 @@ const { parse } = require('url');
const LOKI_EPHEMKEY_HEADER = 'X-Loki-EphemKey'; const LOKI_EPHEMKEY_HEADER = 'X-Loki-EphemKey';
const endpointBase = '/v1/storage_rpc'; const endpointBase = '/v1/storage_rpc';
const seedEndpointBase = '/json_rpc';
const decryptResponse = async (response, address) => { const decryptResponse = async (response, address) => {
try { try {
@ -108,11 +107,10 @@ const rpc = (
method, method,
params, params,
options = {}, options = {},
seedRequest = false endpoint = endpointBase
) => { ) => {
const headers = options.headers || {}; const headers = options.headers || {};
const portString = port ? `:${port}` : ''; const portString = port ? `:${port}` : '';
const endpoint = seedRequest ? seedEndpointBase : endpointBase;
const url = `${address}${portString}${endpoint}`; const url = `${address}${portString}${endpoint}`;
// TODO: The jsonrpc and body field will be ignored on storage server // TODO: The jsonrpc and body field will be ignored on storage server
const body = { const body = {

@ -82,7 +82,7 @@ class LokiSnodeAPI {
'get_service_nodes', 'get_service_nodes',
{}, // Params {}, // Params
{}, // Options {}, // Options
true // Seed request '/json_rpc' // Seed request endpoint
); );
const snodes = result.result.service_node_states; const snodes = result.result.service_node_states;
this.randomSnodePool = snodes.map(snode => ({ this.randomSnodePool = snodes.map(snode => ({

Loading…
Cancel
Save