Skip to content

Commit

Permalink
Merge pull request #1897 from oxen-io/clearnet
Browse files Browse the repository at this point in the history
fix onion path rebuild when snodes count is 12
  • Loading branch information
Bilb authored Sep 6, 2021
2 parents 0d07fb1 + 47977c7 commit 9a5c72c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ts/session/onions/onionPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ async function buildNewOnionPathsWorker() {
);
// TODO: select one guard node and 2 other nodes randomly
let otherNodes = _.differenceBy(allNodes, guardNodes, 'pubkey_ed25519');
if (otherNodes.length < SnodePool.minSnodePoolCount) {
if (otherNodes.length <= SnodePool.minSnodePoolCount) {
window?.log?.warn(
'LokiSnodeAPI::buildNewOnionPaths - Too few nodes to build an onion path! Refreshing pool and retrying'
);
Expand Down
6 changes: 3 additions & 3 deletions ts/session/snode_api/snodePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export async function refreshRandomPool(forceRefresh = false): Promise<void> {
if (fetchedFromDb?.length) {
window?.log?.info(`refreshRandomPool: fetched from db ${fetchedFromDb.length} snodes.`);
randomSnodePool = fetchedFromDb;
if (randomSnodePool.length < minSnodePoolCount) {
if (randomSnodePool.length <= minSnodePoolCount) {
window?.log?.warn('refreshRandomPool: not enough snodes in db, going to fetch from seed');
} else {
return;
Expand All @@ -279,9 +279,9 @@ export async function refreshRandomPool(forceRefresh = false): Promise<void> {
}

// we don't have nodes to fetch the pool from them, so call the seed node instead.
if (randomSnodePool.length < minSnodePoolCount) {
if (randomSnodePool.length <= minSnodePoolCount) {
window?.log?.info(
`refreshRandomPool: NOT enough snodes to fetch from them ${randomSnodePool.length} < ${minSnodePoolCount}, so falling back to seedNodes ${seedNodes?.length}`
`refreshRandomPool: NOT enough snodes to fetch from them ${randomSnodePool.length} <= ${minSnodePoolCount}, so falling back to seedNodes ${seedNodes?.length}`
);

randomSnodePool = await exports.refreshRandomPoolDetail(seedNodes);
Expand Down
2 changes: 1 addition & 1 deletion ts/test/session/unit/onion/OnionErrors_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('OnionPathsErrors', () => {

beforeEach(async () => {
guardPubkeys = TestUtils.generateFakePubKeys(3).map(n => n.key);
otherNodesPubkeys = TestUtils.generateFakePubKeys(12).map(n => n.key);
otherNodesPubkeys = TestUtils.generateFakePubKeys(13).map(n => n.key);

SNodeAPI.Onions.resetSnodeFailureCount();

Expand Down

0 comments on commit 9a5c72c

Please sign in to comment.