diff --git a/src/server.ts b/src/server.ts index 9cdad9a7..03bddb12 100644 --- a/src/server.ts +++ b/src/server.ts @@ -18,7 +18,7 @@ import { sleep, cleanBadNodes, initSyncTime, - updateEdgeNodeConfig, + updateRequestRetries, } from './utils' import { router as logRoute } from './routes/log' import { router as authenticate } from './routes/authenticate' @@ -208,12 +208,12 @@ setupArchiverDiscovery({ debug_info.txRecordingStartTime = config.recordTxStatus ? Date.now() : 0 setConsensorNode() initSyncTime() - updateEdgeNodeConfig() + updateRequestRetries() setInterval(updateNodeList, config.nodelistRefreshInterval) setInterval(saveTxStatus, 5000) setInterval(checkArchiverHealth, 60000) setInterval(cleanBadNodes, 60000) - setInterval(updateEdgeNodeConfig, 60000 * 5) + setInterval(updateRequestRetries, 60000 * 5) extendedServer.listen(port, function () { console.log(`JSON RPC Server listening on port ${port} and chainId is ${chainId}.`) setupDatabase() diff --git a/src/utils.ts b/src/utils.ts index 8963facb..8be49512 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -44,8 +44,6 @@ export const node = { port: 9001, } -let rotationEdgeToAvoid = 0 - const badNodesMap: Map = new Map() const verbose = config.verbose @@ -151,18 +149,20 @@ export async function updateNodeList(tryInfinate = false): Promise { } export function removeFromNodeList(ip: string, port: string): void { + console.log(`Removing node ${ip}:${port} from nodeList`) nodeList = nodeList.filter((node) => node.ip !== ip || node.port !== Number(port)) + console.log(nodeList.map((node) => `${node.port}`)) } -export async function updateEdgeNodeConfig(): Promise { - console.log(`Updating rotationEdgeToAvoid configuration`) +export async function updateRequestRetries(): Promise { + console.log(`Updating defaultRequestRetry configuration`) const res = await requestWithRetry(RequestMethod.Get, `/netconfig`) if (res.data && res.data.config) { const newRotationEdgeToAvoid = res.data.config.p2p.rotationEdgeToAvoid - rotationEdgeToAvoid = newRotationEdgeToAvoid - console.log(`Setting rotationEdgeToAvoid to ${newRotationEdgeToAvoid}`) + config.defaultRequestRetry = newRotationEdgeToAvoid * 2 + console.log(`Setting request retries to ${config.defaultRequestRetry}`) } else if (res.data && res.data.error) { console.log(`Error getting rotationEdgeToAvoid configuration: ${res.data.error}`) }