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

floodsub::lib::Message vs floodsub::rpc_proto::Message #517

Closed
jamesray1 opened this issue Sep 25, 2018 · 1 comment
Closed

floodsub::lib::Message vs floodsub::rpc_proto::Message #517

jamesray1 opened this issue Sep 25, 2018 · 1 comment

Comments

@jamesray1
Copy link
Contributor

jamesray1 commented Sep 25, 2018

Why do you use Message in floodsub::lib when it differs from floodsub::rpc_proto::Message?

floodsub::lib:

/// A message received by the floodsub system.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Message {
    /// Remote that sent the message.
    pub source: Multiaddr,

    /// Content of the message. Its meaning is out of scope of this library.
    pub data: Vec<u8>,

    /// List of topics of this message.
    ///
    /// Each message can belong to multiple topics at once.
    pub topics: Vec<TopicHash>,
}

floodsub::rpc_proto::Message:

#[derive(PartialEq,Clone,Default)]
pub struct Message {
    // message fields
    from: ::protobuf::SingularField<::std::vec::Vec<u8>>,
    data: ::protobuf::SingularField<::std::vec::Vec<u8>>,
    seqno: ::protobuf::SingularField<::std::vec::Vec<u8>>,
    topicIDs: ::protobuf::RepeatedField<::std::string::String>,
    // special fields
    unknown_fields: ::protobuf::UnknownFields,
    cached_size: ::protobuf::CachedSize,
}

Related: #473.

@jamesray1 jamesray1 changed the title Why do you use Message in floodsub::lib when it differs from floodsub::rpc_proto::Message? floodsub::lib::Message vs floodsub::rpc_proto::Message Sep 25, 2018
@tomaka
Copy link
Member

tomaka commented Sep 25, 2018

We don't expose the message struct of the protobuf library because we don't want users to have to be aware of the fact that we use this library as part of the implementation.
By doing so, we can replace protobuf with something else if necessary, without having to modify the Message struct. And therefore the users of floodsub also will not need to make any adjustement.

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

No branches or pull requests

2 participants