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

Commit

Permalink
Improve docs wording and simplify test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cobward committed Feb 28, 2022
1 parent a1bc611 commit 39c4f16
Showing 1 changed file with 4 additions and 6 deletions.
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

0 comments on commit 39c4f16

Please sign in to comment.