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

feat: use the lowest latency peer for light protocols #1520

Closed
wants to merge 95 commits into from

Conversation

danisharora099
Copy link
Collaborator

@danisharora099 danisharora099 commented Aug 31, 2023

!!#1469 should be merged first!!

Problem

During selection of peers to be used for light protocols, the selection currently happens randomly. This is not ideal, as we might potentially be communicating with a higher latency node, while an option to use a faster node might exist.

Ref: #1465 #1497

Solution

  1. ping all peers and select the peer with the lowest latency.
  2. fallback to randomization (shouldn't happen)

@danisharora099 danisharora099 marked this pull request as draft September 5, 2023 12:16
@@ -4,25 +4,59 @@ import type { KeepAliveOptions } from "@waku/interfaces";
import debug from "debug";
import type { PingService } from "libp2p/ping";

import { createEncoder } from "../index.js";
import { createEncoder } from "./message/version_0.js";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while unrelated to this PR, this was causing a cyclic dependency error that surfaced during this PR


export const RelayPingContentTopic = "/relay-ping/1/ping/null";
const log = debug("waku:keep-alive");

export class KeepAliveManager {
private static instance: KeepAliveManager;
Copy link
Collaborator Author

@danisharora099 danisharora099 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converted this into a singleton for easier access (also consistent with ConnectionManager)

Base automatically changed from feat/px-default to master September 7, 2023 07:45
@danisharora099
Copy link
Collaborator Author

superseded by #1540

@danisharora099 danisharora099 deleted the feat/select-fastest-peer branch September 15, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants