Skip to content

Commit

Permalink
Silence insufficient peers error.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed May 5, 2021
1 parent 12f5031 commit d2654f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn run() -> Result<()> {
}
Command::DialAddress(peer, addr) => {
if peer != peer_id {
ipfs.dial_address(&peer, addr)?;
ipfs.dial_address(&peer, addr);
}
}
Command::Get(cid) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> anyhow::Result<()> {
let ipfs = Ipfs::<Sp>::new(config).await?;
let peer: PeerId = "QmRSGx67Kq8w7xSBDia7hQfbfuvauMQGgxcwSWw976x4BS".parse()?;
let addr: Multiaddr = "/ip4/54.173.33.96/tcp/4001".parse()?;
ipfs.dial_address(&peer, addr)?;
ipfs.dial_address(&peer, addr);

// 10 random bytes
let _cid_rand10: Cid = "QmXQsqVRpp2W7fbYZHi4aB2Xkqfd3DpwWskZoLVEYigMKC".parse()?;
Expand Down
13 changes: 9 additions & 4 deletions src/net/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,17 @@ impl<P: StoreParams> NetworkBackendBehaviour<P> {
}

pub fn publish(&mut self, topic: &str, msg: Vec<u8>) -> Result<()> {
use libp2p::gossipsub::error::PublishError;
if let Some(gossipsub) = self.gossipsub.as_mut() {
let gossip_topic = IdentTopic::new(topic);
gossipsub
.publish(gossip_topic, msg)
.map_err(GossipsubPublishError)?;
Ok(())
match gossipsub.publish(gossip_topic, msg) {
Ok(_) => Ok(()),
Err(PublishError::InsufficientPeers) => {
tracing::trace!("publish: insufficient peers.");
Ok(())
}
Err(err) => Err(GossipsubPublishError(err).into()),
}
} else {
Err(DisabledProtocol.into())
}
Expand Down

0 comments on commit d2654f6

Please sign in to comment.