@@ -397,8 +397,8 @@ public Multihash ls() throws IOException {
397397 /*public String migrate(boolean allowDowngrade) throws IOException {
398398 return retrieveString("repo/migrate?allow-downgrade=" + allowDowngrade);
399399 }*/
400- public Map stat (boolean sizeOnly , boolean humanReadable ) throws IOException {
401- return retrieveMap ( "repo/stat?size-only=" + sizeOnly + "&human=" + humanReadable );
400+ public RepoStat stat (boolean sizeOnly ) throws IOException {
401+ return RepoStat . fromJson ( retrieveAndParse ( "repo/stat?size-only=" + sizeOnly ) );
402402 }
403403 public Map verify () throws IOException {
404404 return retrieveMap ("repo/verify" );
@@ -812,8 +812,8 @@ public String reprovide() throws IOException {
812812 public Map stat () throws IOException {
813813 return retrieveMap ("bitswap/stat" );
814814 }
815- public Map stat (boolean verbose , boolean humanReadable ) throws IOException {
816- return retrieveMap ("bitswap/stat?verbose=" + verbose + "&human=" + humanReadable );
815+ public Map stat (boolean verbose ) throws IOException {
816+ return retrieveMap ("bitswap/stat?verbose=" + verbose );
817817 }
818818 public Map wantlist (Multihash peerId ) throws IOException {
819819 return retrieveMap ("bitswap/wantlist?peer=" + peerId );
@@ -856,6 +856,9 @@ public List<MultiAddress> rmAll() throws IOException {
856856 public class Swarm {
857857 public List <Peer > peers () throws IOException {
858858 Map m = retrieveMap ("swarm/peers?stream-channels=true" );
859+ if (m .get ("Peers" ) == null ) {
860+ return Collections .emptyList ();
861+ }
859862 return ((List <Object >)m .get ("Peers" )).stream ()
860863 .flatMap (json -> {
861864 try {
@@ -981,8 +984,8 @@ public Map id() throws IOException {
981984 }
982985
983986 public class Stats {
984- public Map bitswap (boolean verbose , boolean humanReadable ) throws IOException {
985- return retrieveMap ("stats/bitswap?verbose=" + verbose + "&human=" + humanReadable );
987+ public Map bitswap (boolean verbose ) throws IOException {
988+ return retrieveMap ("stats/bitswap?verbose=" + verbose );
986989 }
987990 public Map bw () throws IOException {
988991 return retrieveMap ("stats/bw" );
@@ -993,8 +996,8 @@ public Map dht() throws IOException {
993996 public Map provide () throws IOException {
994997 return retrieveMap ("stats/provide" );
995998 }
996- public Map repo (boolean sizeOnly , boolean humanReadable ) throws IOException {
997- return retrieveMap ( "stats/repo?size-only=" + sizeOnly + "&human=" + humanReadable );
999+ public RepoStat repo (boolean sizeOnly ) throws IOException {
1000+ return RepoStat . fromJson ( retrieveAndParse ( "stats/repo?size-only=" + sizeOnly ) );
9981001 }
9991002 }
10001003
0 commit comments