Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

feat(rpc, api): add gossipsub IPC methods #296

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

nathanielc
Copy link

Closes #16

This change is based off n0-computer/iroh#669 and removes any logic from that PR not related to exposing the gossipsub IPC methods

This commit represents the state of n0-computer/iroh#669
before the repo changes.
This change removes any changes that were not related to exposing
gossipsub subscription events. Additionally it updates tests to pass
using the new APIs.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum GossipsubEvent {
Subscribed {
Copy link
Contributor

Choose a reason for hiding this comment

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

In ipfs-embed we had subscribe return just the messages.

But I guess it can be useful to have the subscribe/unsubscribe events as well...

Copy link
Author

Choose a reason for hiding this comment

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

I know some of the tests make use of the subscribe/unsubscribe messages and generally I agree it makes sense to expose them to consumers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you can always filter them out if you don't want them.

The topic was inside the both the message event and the message data.
It now only lives within the message data section. This avoids ambiguity
of knowing which topic to use and keeping them synchronized.
@nathanielc
Copy link
Author

@rklaehn Thanks for the review. I have addressed all feedback.

enum PeerState {
Connected(ConnectionId),
Responsive(ConnectionId, ProtocolId),
Unresponsive,
#[default]
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I understand: this is not really related to the PR, right?

Keep it in, it seems reasonable...

Copy link
Author

Choose a reason for hiding this comment

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

Correct, clippy complained about it so I fixed it. Not sure what changed with clippy to start complaining about it but figured it was a good fix anyway.

use crate::{
behaviour::{Event, NodeBehaviour},
rpc::{self, RpcMessage},
Config,
};

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this need to be serializable now? The new rpc message just serializes GossipsubEvent, not this.

Copy link
Author

Choose a reason for hiding this comment

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

Correct as well, removed those bits and everything passes tests.

@nathanielc
Copy link
Author

Looks like there is a flaky transfer test. I'll try and hunt it down and get a fix.

@nathanielc
Copy link
Author

Ok I have not been able to find the source of the flaky test 😞. However I did trace it down into the bitswap code session management. From what I can tell a session worker is somehow dropped and it stops polling the future and then no progress is made causing a deadlock.

I currently don't have time to continue to chase this bug however I would still like to move forward with this PR as it does not appear to have introduced this bug. Thoughts?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(rpc, api): add network_events, and Gossipsub IPC methods
3 participants