mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-05 15:42:16 +00:00
The `unreachable_pub` lint makes us aware of uses of `pub` that are not actually reachable from the crate root. This is considered good because it means reading a `pub` somewhere means it is actually public API. Some of our crates are quite large and keeping their entire API surface in your head is difficult. We should strive for most items being `pub(crate)`. This lint helps us enforce that. Pull-Request: #3735.
61 lines
2.2 KiB
Rust
61 lines
2.2 KiB
Rust
// Copyright 2018 Parity Technologies (UK) Ltd.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
// to deal in the Software without restriction, including without limitation
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//! Implementation of the [floodsub](https://github.com/libp2p/specs/blob/master/pubsub/README.md) protocol.
|
|
|
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
|
|
|
use libp2p_identity::PeerId;
|
|
|
|
pub mod protocol;
|
|
|
|
mod layer;
|
|
mod topic;
|
|
|
|
mod proto {
|
|
#![allow(unreachable_pub)]
|
|
include!("generated/mod.rs");
|
|
pub(crate) use self::floodsub::pb::{mod_RPC::SubOpts, Message, RPC};
|
|
}
|
|
|
|
pub use self::layer::{Floodsub, FloodsubEvent};
|
|
pub use self::protocol::{FloodsubMessage, FloodsubRpc};
|
|
pub use self::topic::Topic;
|
|
|
|
/// Configuration options for the Floodsub protocol.
|
|
#[derive(Debug, Clone)]
|
|
pub struct FloodsubConfig {
|
|
/// Peer id of the local node. Used for the source of the messages that we publish.
|
|
pub local_peer_id: PeerId,
|
|
|
|
/// `true` if messages published by local node should be propagated as messages received from
|
|
/// the network, `false` by default.
|
|
pub subscribe_local_messages: bool,
|
|
}
|
|
|
|
impl FloodsubConfig {
|
|
pub fn new(local_peer_id: PeerId) -> Self {
|
|
Self {
|
|
local_peer_id,
|
|
subscribe_local_messages: false,
|
|
}
|
|
}
|
|
}
|