summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@fastmail.fm>2018-01-23 20:24:44 -0500
committerFerris Tseng <ferristseng@fastmail.fm>2018-01-23 20:24:44 -0500
commit1661d3e4a90ea2797b3b0485c9396b0b79473e0c (patch)
tree2fe85a30d67cfb38b2d8fa2da99838e7053206a7
parenta6c716e771ac041323fefcc1d04dc98490c38eff (diff)
add /bitswap/reprovide
-rw-r--r--ipfs-api/src/client.rs23
-rw-r--r--ipfs-api/src/request/bitswap.rs8
-rw-r--r--ipfs-api/src/response/bitswap.rs2
-rw-r--r--ipfs-cli/src/command/bitswap.rs6
4 files changed, 38 insertions, 1 deletions
diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs
index 564415f..7a4fbed 100644
--- a/ipfs-api/src/client.rs
+++ b/ipfs-api/src/client.rs
@@ -362,7 +362,28 @@ impl IpfsClient {
self.request(&request::BitswapLedger { peer }, None)
}
- // TODO /bitswap/reprovide
+ /// Triggers a reprovide.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// # extern crate ipfs_api;
+ /// # extern crate tokio_core;
+ /// #
+ /// use ipfs_api::IpfsClient;
+ /// use tokio_core::reactor::Core;
+ ///
+ /// # fn main() {
+ /// let mut core = Core::new().unwrap();
+ /// let client = IpfsClient::default(&core.handle());
+ /// let req = client.bitswap_reprovide();
+ /// # }
+ /// ```
+ ///
+ #[inline]
+ pub fn bitswap_reprovide(&self) -> AsyncResponse<response::BitswapReprovideResponse> {
+ self.request_empty(&request::BitswapReprovide, None)
+ }
/// Returns some stats about the bitswap agent.
///
diff --git a/ipfs-api/src/request/bitswap.rs b/ipfs-api/src/request/bitswap.rs
index 1f795bb..326778e 100644
--- a/ipfs-api/src/request/bitswap.rs
+++ b/ipfs-api/src/request/bitswap.rs
@@ -17,6 +17,14 @@ impl<'a> ApiRequest for BitswapLedger<'a> {
const PATH: &'static str = "/bitswap/ledger";
}
+pub struct BitswapReprovide;
+
+impl_skip_serialize!(BitswapReprovide);
+
+impl ApiRequest for BitswapReprovide {
+ const PATH: &'static str = "/bitswap/reprovide";
+}
+
pub struct BitswapStat;
impl_skip_serialize!(BitswapStat);
diff --git a/ipfs-api/src/response/bitswap.rs b/ipfs-api/src/response/bitswap.rs
index 69b9705..c1039de 100644
--- a/ipfs-api/src/response/bitswap.rs
+++ b/ipfs-api/src/response/bitswap.rs
@@ -18,6 +18,8 @@ pub struct BitswapLedgerResponse {
pub exchanged: u64,
}
+pub type BitswapReprovideResponse = ();
+
#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct BitswapStatResponse {
diff --git a/ipfs-cli/src/command/bitswap.rs b/ipfs-cli/src/command/bitswap.rs
index 33f88ef..a63c21f 100644
--- a/ipfs-cli/src/command/bitswap.rs
+++ b/ipfs-cli/src/command/bitswap.rs
@@ -19,6 +19,9 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> {
(about: "Show the current ledger for a peer")
(@arg PEER: +required "Peer to inspect")
)
+ (@subcommand reprovide =>
+ (about: "Triggers a reprovide")
+ )
(@subcommand stat =>
(about: "Show some diagnostic information on the bitswap agent")
)
@@ -46,6 +49,9 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) {
println!(" exchanged : {}", ledger.exchanged);
println!();
}
+ ("reprovide", _) => {
+ core.run(client.bitswap_reprovide()).expect(EXPECTED_API);
+ }
("stat", _) => {
let stat = core.run(client.bitswap_stat()).expect(EXPECTED_API);