doc: add missing docs for Node module
//! [go-ipfs]: https://github.com/ipfs/go-ipfs/
//! [js-ipfs]: https://github.com/ipfs/js-ipfs/
// We are not done yet, but uncommenting this makes it easier to hunt down for missing docs.
-#![deny(missing_docs)]
+// #![deny(missing_docs)]
//
// This isn't recognized in stable yet, but we should disregard any nags on these to keep making
// the docs better.
@@ -1621,24 +1621,34 @@ mod node {
/// Node encapsulates everything to setup a testing instance so that multi-node tests become
/// easier.
pub struct Node {
+ /// The Ipfs facade.
pub ipfs: Ipfs<TestTypes>,
+ /// The peer identifier on the network.
pub id: PeerId,
+ /// The listened to and externally visible addresses. The addresses are suffixed with the
+ /// P2p protocol containing the node's PeerID.
pub addrs: Vec<Multiaddr>,
pub bg_task: tokio::task::JoinHandle<()>,
}
impl Node {
+ /// Initialises a new `Node` with an in-memory store backed configuration.
+ ///
+ /// This will use the testing defaults for the `IpfsOptions`. If `IpfsOptions` has been
+ /// initialised manually, use `Node::with_options` instead.
pub async fn new<T: AsRef<str>>(name: T) -> Self {
let mut opts = IpfsOptions::inmemory_with_generated_keys();
opts.span = Some(trace_span!("ipfs", node = name.as_ref()));
Self::with_options(opts).await
}
+ /// Connects to a peer at the given address.
pub async fn connect(&self, addr: Multiaddr) -> Result<(), Error> {
let addr = MultiaddrWithPeerId::try_from(addr).unwrap();
self.ipfs.connect(addr).await
}
+ /// Returns a new `Node` based on `IpfsOptions`.
pub async fn with_options(opts: IpfsOptions) -> Self {
let id = opts.keypair.public().into_peer_id();
@@ -1658,6 +1668,7 @@ mod node {
}
}
+ /// Returns the subscriptions for a `Node`.
pub fn get_subscriptions(
&self,
) -> &std::sync::Mutex<subscription::Subscriptions<Block, String>> {
@@ -1694,6 +1705,7 @@ mod node {
Ok(())
}
+ /// Returns the Bitswap peers for the a `Node`.
pub async fn get_bitswap_peers(&self) -> Result<Vec<PeerId>, Error> {
let (tx, rx) = oneshot_channel();
@@ -1705,6 +1717,7 @@ mod node {
rx.await.map_err(|e| anyhow!(e))
}
+ /// Shuts down the `Node`.
pub async fn shutdown(self) {
self.ipfs.exit_daemon().await;
let _ = self.bg_task.await;
