refactor getRandomPoolLength out of markRandomNodeUnreachable

pull/988/head
Ryan Tharp 6 years ago
parent 8bf77ce44f
commit 7a0e972ca4

@ -73,9 +73,8 @@ const sendToProxy = async (options = {}, targetNode, retryNumber = 0) => {
// remove // remove
// but which the proxy or the target... // but which the proxy or the target...
// we got a ton of randomPool nodes, let's just not worry about this one // we got a ton of randomPool nodes, let's just not worry about this one
const randomPoolRemainingCount = lokiSnodeAPI.markRandomNodeUnreachable( lokiSnodeAPI.markRandomNodeUnreachable(randSnode);
randSnode const randomPoolRemainingCount = lokiSnodeAPI.getRandomPoolLength();
);
log.warn( log.warn(
`lokiRpc sendToProxy`, `lokiRpc sendToProxy`,
`snode ${randSnode.ip}:${randSnode.port} to ${targetNode.ip}:${ `snode ${randSnode.ip}:${randSnode.port} to ${targetNode.ip}:${
@ -99,9 +98,8 @@ const sendToProxy = async (options = {}, targetNode, retryNumber = 0) => {
// but the target node // but the target node
// we got a ton of randomPool nodes, let's just not worry about this one // we got a ton of randomPool nodes, let's just not worry about this one
const randomPoolRemainingCount = lokiSnodeAPI.markRandomNodeUnreachable( lokiSnodeAPI.markRandomNodeUnreachable(randSnode);
randSnode const randomPoolRemainingCount = lokiSnodeAPI.getRandomPoolLength();
);
log.warn( log.warn(
`lokiRpc sendToProxy`, `lokiRpc sendToProxy`,
`snode ${randSnode.ip}:${randSnode.port} to ${targetNode.ip}:${ `snode ${randSnode.ip}:${randSnode.port} to ${targetNode.ip}:${

@ -185,6 +185,9 @@ class LokiSnodeAPI {
this.randomSnodePool, this.randomSnodePool,
_.find(this.randomSnodePool, { ip: snode.ip, port: snode.port }) _.find(this.randomSnodePool, { ip: snode.ip, port: snode.port })
); );
}
getRandomPoolLength() {
return this.randomSnodePool.length; return this.randomSnodePool.length;
} }
@ -281,7 +284,8 @@ class LokiSnodeAPI {
const snodes = result.snodes.filter(tSnode => tSnode.ip !== '0.0.0.0'); const snodes = result.snodes.filter(tSnode => tSnode.ip !== '0.0.0.0');
return snodes; return snodes;
} catch (e) { } catch (e) {
const randomPoolRemainingCount = this.markRandomNodeUnreachable(snode); this.markRandomNodeUnreachable(snode);
const randomPoolRemainingCount = this.getRandomPoolLength();
log.error( log.error(
'loki_snodes:::getSnodesForPubkey - error', 'loki_snodes:::getSnodesForPubkey - error',
e.code, e.code,

Loading…
Cancel
Save