Skip to content

Commit 5e81593

Browse files
committed
add items to stats api
1 parent 479654d commit 5e81593

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/main/java/io/ipfs/api/IPFS.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public IPFS(String host, int port, String version, int connectTimeoutMillis, int
9292
throw new RuntimeException(e);
9393
}
9494
}
95-
95+
9696
/**
9797
* Configure a HTTP client timeout
9898
* @param timeout (default 0: infinite timeout)
@@ -102,6 +102,10 @@ public IPFS timeout(int timeout) {
102102
return new IPFS(host, port, version, timeout, timeout, protocol.equals("https"));
103103
}
104104

105+
public String shutdown() throws IOException {
106+
return retrieveString("shutdown");
107+
}
108+
105109
public List<MerkleNode> add(NamedStreamable file) throws IOException {
106110
return add(file, false);
107111
}
@@ -829,9 +833,21 @@ public Map id() throws IOException {
829833
}
830834

831835
public class Stats {
836+
public Map bitswap(boolean verbose, boolean humanReadable) throws IOException {
837+
return retrieveMap("stats/bitswap?verbose=" + verbose + "&human=" + humanReadable);
838+
}
832839
public Map bw() throws IOException {
833840
return retrieveMap("stats/bw");
834841
}
842+
public Map dht() throws IOException {
843+
return retrieveMap("stats/dht");
844+
}
845+
public Map provide() throws IOException {
846+
return retrieveMap("stats/provide");
847+
}
848+
public Map repo(boolean sizeOnly, boolean humanReadable) throws IOException {
849+
return retrieveMap("stats/repo?size-only=" + sizeOnly + "&human=" + humanReadable);
850+
}
835851
}
836852

837853
// Tools

src/test/java/io/ipfs/api/APITest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,11 @@ public void localId() throws Exception {
728728
@Test
729729
public void statsTest() throws IOException {
730730
Map stats = ipfs.stats.bw();
731+
Map bitswap = ipfs.stats.bitswap(true, true);
732+
Map dht = ipfs.stats.dht();
733+
//{"Message":"can only return stats if Experimental.AcceleratedDHTClient is enabled","Code":0,"Type":"error"}
734+
//requires Map provide = ipfs.stats.provide();
735+
Map repo = ipfs.stats.repo(false, true);
731736
}
732737

733738
public void resolveTest() throws IOException {

0 commit comments

Comments
 (0)