@@ -397,8 +397,8 @@ public Multihash ls() throws IOException {
397
397
/*public String migrate(boolean allowDowngrade) throws IOException {
398
398
return retrieveString("repo/migrate?allow-downgrade=" + allowDowngrade);
399
399
}*/
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 ) );
402
402
}
403
403
public Map verify () throws IOException {
404
404
return retrieveMap ("repo/verify" );
@@ -812,8 +812,8 @@ public String reprovide() throws IOException {
812
812
public Map stat () throws IOException {
813
813
return retrieveMap ("bitswap/stat" );
814
814
}
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 );
817
817
}
818
818
public Map wantlist (Multihash peerId ) throws IOException {
819
819
return retrieveMap ("bitswap/wantlist?peer=" + peerId );
@@ -856,6 +856,9 @@ public List<MultiAddress> rmAll() throws IOException {
856
856
public class Swarm {
857
857
public List <Peer > peers () throws IOException {
858
858
Map m = retrieveMap ("swarm/peers?stream-channels=true" );
859
+ if (m .get ("Peers" ) == null ) {
860
+ return Collections .emptyList ();
861
+ }
859
862
return ((List <Object >)m .get ("Peers" )).stream ()
860
863
.flatMap (json -> {
861
864
try {
@@ -981,8 +984,8 @@ public Map id() throws IOException {
981
984
}
982
985
983
986
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 );
986
989
}
987
990
public Map bw () throws IOException {
988
991
return retrieveMap ("stats/bw" );
@@ -993,8 +996,8 @@ public Map dht() throws IOException {
993
996
public Map provide () throws IOException {
994
997
return retrieveMap ("stats/provide" );
995
998
}
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 ) );
998
1001
}
999
1002
}
1000
1003
0 commit comments