Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Expose Floodsub target_peer list. #498

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Improve docs wording and simplify test.
  • Loading branch information
cobward committed Feb 28, 2022
commit 39c4f1647426913ce70cc9fb4fe51e4ae198876e
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,8 @@ impl<Types: IpfsTypes> Ipfs<Types> {

/// Add a peer to list of nodes to propagate messages to.
///
/// Unless a peer is added to the list in this way it will not receive any pubsub messages from this node.
/// A peer will not receive any pubsub messages from this node until it is added using this function,
/// unless it has added this node in the same way.
pub async fn pubsub_add_peer(&self, peer_id: PeerId) -> Result<(), Error> {
async move {
let (tx, rx) = oneshot_channel::<()>();
Expand All @@ -777,7 +778,7 @@ impl<Types: IpfsTypes> Ipfs<Types> {

/// Remove a peer from the list of nodes that messages are propagated to.
///
/// This will not stop messages being sent to the specified peers for subscribed topics which have already been communicated.
/// Calling this function will not stop messages being sent to the specified peers for subscribed topics which have already been communicated.
pub async fn pubsub_remove_peer(&self, peer_id: PeerId) -> Result<(), Error> {
async move {
let (tx, rx) = oneshot_channel::<()>();
Expand Down Expand Up @@ -1878,11 +1879,8 @@ mod tests {
#[tokio::test]
async fn test_pubsub_send_and_receive() {
let alice = Node::new("alice").await;
let alice_addr: Multiaddr = "/ip4/127.0.0.1/tcp/10001".parse().unwrap();
alice.add_listening_address(alice_addr).await.unwrap();
let bob = Node::new("bob").await;
let bob_addr: Multiaddr = "/ip4/127.0.0.1/tcp/10002".parse().unwrap();
bob.add_listening_address(bob_addr.clone()).await.unwrap();
let bob_addr = bob.addrs_local().await.unwrap()[0].clone();

let topic = String::from("test_topic");
alice
Expand Down