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: support hello message with protocols #5371

Merged
merged 2 commits into from
Nov 9, 2023

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Nov 9, 2023

This introduces the Protocols and HelloMessageWithProtocols type, which is now required when handshaking p2p stream.

this way we can support any protocol, because message numbers are not exchanged via the handshake we need to rely on input data when computing the offsets for sharedcapabilities.

The Protocols type provides this additional information.

This will require a few followups to make it a bit nicer overall

@mattsse mattsse added the A-networking Related to networking in general label Nov 9, 2023
Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

lgtm, makes sense!

Comment on lines -693 to +706

let shared_capability = SharedCapability::new(&name, *version as u8, offset)?;

match shared_capability {
SharedCapability::UnknownCapability { .. } => {
// Capabilities which are not shared are ignored
debug!("unknown capability: name={:?}, version={}", name, version,);
let proto_version = shared_capabilities.get(&name).expect("shared; qed");

// TODO(mattsse): track shared caps
}
SharedCapability::Eth { .. } => {
// increment the offset if the capability is known
offset += shared_capability.num_messages()?;
let shared_capability = SharedCapability::new(&name, proto_version.version as u8, offset)?;

shared_with_offsets.push(shared_capability);
}
}
offset += proto_version.messages;
shared_with_offsets.push(shared_capability);
Copy link
Member

Choose a reason for hiding this comment

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

ah, this sense compared to the match, SharedCapability would have had to be extended for people adding new subprotocols. Whereas this is more flexible

@Rjected Rjected added this pull request to the merge queue Nov 9, 2023
Merged via the queue into main with commit 2488aa0 Nov 9, 2023
@Rjected Rjected deleted the matt/support-hello-message-with-protocols branch November 9, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Related to networking in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants