-
Notifications
You must be signed in to change notification settings - Fork 23
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 custom compat protocol name #42
base: master
Are you sure you want to change the base?
Conversation
7e0bdf4
to
adef753
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I had to mute github notifications for a while.
This change looks good to me, just two points to discuss.
src/behaviour.rs
Outdated
@@ -26,6 +26,8 @@ use libp2p::core::either::EitherOutput; | |||
use libp2p::core::{connection::ConnectionId, Multiaddr, PeerId}; | |||
use libp2p::swarm::derive_prelude::{ConnectionClosed, DialFailure, FromSwarm, ListenFailure}; | |||
#[cfg(feature = "compat")] | |||
use libp2p::swarm::SubstreamProtocol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fold this into the following import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
impl UpgradeInfo for CompatMessage { | ||
type Info = &'static [u8]; | ||
type InfoIter = iter::Once<Self::Info>; | ||
|
||
fn protocol_info(&self) -> Self::InfoIter { | ||
iter::once(b"/ipfs/bitswap/1.2.0") | ||
unimplemented!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This smells bad: why not instead remove this impl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It requires more refactoring to remove UpgradeInfo
impl for CompatMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That refactoring is the required proof that this unimplemented!()
won’t panic at runtime, though. In other words, I find it reasonable to demand that a production ready library does not contain unimplemented!()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense! However, it's been too long since I made the PR, and I do need some extra time to pick up the context and made the change.
Changes:
go-bitswap
compatible nodelibipld
to make life easier when there're version conflicts in downstream crates. (e.g.[email protected]
depends on a differentcid
version fromfvm_ipld_blockstore
) and it's not yet possible to upgradefvm_ipld_blockstore
, see chore: upgradecid
,multihash
,libipld-core
crates filecoin-project/ref-fvm#1380 (comment)Background:
go-bitswap
allows customizing the protocol name with itsSettings.Prefix
API, e.g. lotus uses"/chain"
prefix,rust-bitswap
should be capable of matching the protocol name incompat
mode. Please let me know your feedback, thanks!