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

chore: minor refactoring for protocols #1762

Merged
merged 11 commits into from
Jan 11, 2024
Merged

chore: minor refactoring for protocols #1762

merged 11 commits into from
Jan 11, 2024

Conversation

danisharora099
Copy link
Collaborator

@danisharora099 danisharora099 commented Dec 18, 2023

BaseProtocol housed getPeer as well as getPeers with very close naming.

  • getPeers is used to find peers for a protocol, & filter according to discovery mechanism prioritization.
    • is being used by Filter, LightPush, Store
  • getPeer simply found lowest latency peer for the protocol (while this was not required by the way it was being used after we introduced getPeers)
    • is being used by Metadata and Peer Exchange

This PR:

  • removes the getPeer function and directly uses peerStore.get(peerId) to find a peer
    • this is done for peer-exchange and metadata -- this was being used to send a request to that peer
    • peerId is made mandatory on the params for peer-exchange query
  • getPeers is used in all other protocols and the lowest latency sorting is added

Notes:

@danisharora099 danisharora099 requested a review from a team as a code owner December 18, 2023 11:51
Copy link

github-actions bot commented Dec 18, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 82.02 KB (0%) 1.7 s (0%) 1.2 s (-14.72% 🔽) 2.8 s
Waku Simple Light Node 261.47 KB (-0.03% 🔽) 5.3 s (-0.03% 🔽) 1.9 s (-17.06% 🔽) 7.1 s
ECIES encryption 31.97 KB (0%) 640 ms (0%) 379 ms (-59.4% 🔽) 1.1 s
Symmetric encryption 31.96 KB (0%) 640 ms (0%) 644 ms (+6.11% 🔺) 1.3 s
DNS discovery 123.17 KB (0%) 2.5 s (0%) 1.3 s (-6.94% 🔽) 3.7 s
Privacy preserving protocols 119.34 KB (0%) 2.4 s (0%) 1.3 s (-3.59% 🔽) 3.7 s
Light protocols 79.44 KB (-0.15% 🔽) 1.6 s (-0.15% 🔽) 1.3 s (+24.27% 🔺) 2.9 s
History retrieval protocols 78.33 KB (-0.15% 🔽) 1.6 s (-0.15% 🔽) 892 ms (-46.03% 🔽) 2.5 s
Deterministic Message Hashing 5.92 KB (0%) 119 ms (0%) 159 ms (-27.93% 🔽) 277 ms

Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

I am confused by the tests deletion

maxBootstrapPeers
);

const sortedFilteredPeers = await sortPeersByLatency(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Documentation of the function needs to be updated.

Copy link
Collaborator Author

@danisharora099 danisharora099 Dec 20, 2023

Choose a reason for hiding this comment

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

Can you elaborate?

Doc for sortPeersByLatency was updated.
For the parent function getPeers, it has a generic definition that wasn't falsy. Updated it for more verbosity: 02aeab8

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fryorcraken merging this now
please let me know if you would prefer any follow up -- thanks!

@danisharora099 danisharora099 requested a review from a team December 21, 2023 11:04
Copy link
Collaborator

@weboko weboko left a comment

Choose a reason for hiding this comment

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

lgtm ✅

@danisharora099 danisharora099 merged commit b99f828 into master Jan 11, 2024
9 of 11 checks passed
@danisharora099 danisharora099 deleted the chore/cleanup branch January 11, 2024 11:55
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.

4 participants