Skip to content

Commit

Permalink
Fixed access for IPFS inner classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Oct 23, 2015
1 parent 76d9c28 commit a27ef5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ tests:
jar -cfm Tests.jar def.manifest \
-C build org
rm -f def.manifest
java -cp $(CP):Tests.jar org.junit.runner.JUnitCore org.ipfs.Test
java -cp $(CP):Tests.jar org.junit.runner.JUnitCore org.ipfs.test.Test
28 changes: 14 additions & 14 deletions src/org/ipfs/IPFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ public Map mount(java.io.File ipfsRoot, java.io.File ipnsRoot) throws IOExceptio
}

// level 2 commands
class Refs {
public class Refs {
public List<Multihash> local() throws IOException {
return Arrays.asList(new String(retrieve("refs/local")).split("\n")).stream().map(Multihash::fromBase58).collect(Collectors.toList());
}
}

/* Pinning an object ensures a local copy of it is kept.
*/
class Pin {
public class Pin {
public List<Multihash> add(Multihash hash) throws IOException {
return ((List<Object>)((Map)retrieveAndParse("pin/add?stream-channels=true&arg=" + hash)).get("Pinned"))
.stream()
Expand Down Expand Up @@ -132,15 +132,15 @@ public List<Multihash> rm(Multihash hash, boolean recursive) throws IOException

/* 'ipfs repo' is a plumbing command used to manipulate the repo.
*/
class Repo {
public class Repo {
public Object gc() throws IOException {
return retrieveAndParse("repo/gc");
}
}

/* 'ipfs block' is a plumbing command used to manipulate raw ipfs blocks.
*/
class Block {
public class Block {
public byte[] get(Multihash hash) throws IOException {
return retrieve("block/get?stream-channels=true&arg=" + hash);
}
Expand All @@ -160,7 +160,7 @@ public Map stat(Multihash hash) throws IOException {

/* 'ipfs object' is a plumbing command used to manipulate DAG objects directly. {Object} is a subset of {Block}
*/
class IPFSObject {
public class IPFSObject {
public List<MerkleNode> put(List<byte[]> data) throws IOException {
Multipart m = new Multipart("http://" + host + ":" + port + version+"object/put?stream-channels=true", "UTF-8");
for (byte[] f : data)
Expand Down Expand Up @@ -198,7 +198,7 @@ public MerkleNode _new(Optional<String> template) throws IOException {
// TODO patch
}

class Name {
public class Name {
public Map publish(Multihash hash) throws IOException {
return publish(Optional.empty(), hash);
}
Expand All @@ -213,7 +213,7 @@ public String resolve(Multihash hash) throws IOException {
}
}

class DHT {
public class DHT {
public Map findprovs(Multihash hash) throws IOException {
return retrieveMap("dht/findprovs?arg=" + hash);
}
Expand All @@ -235,7 +235,7 @@ public Map put(String key, String value) throws IOException {
}
}

class File {
public class File {
public Map ls(Multihash path) throws IOException {
return retrieveMap("file/ls?arg=" + path);
}
Expand All @@ -247,7 +247,7 @@ public List<MultiAddress> bootstrap() throws IOException {
return ((List<String>)retrieveMap("bootstrap/").get("Peers")).stream().map(x -> new MultiAddress(x)).collect(Collectors.toList());
}

class Bootstrap {
public class Bootstrap {
public List<MultiAddress> list() throws IOException {
return bootstrap();
}
Expand All @@ -269,7 +269,7 @@ public List<MultiAddress> rm(MultiAddress addr, boolean all) throws IOException
component that opens, listens for, and maintains connections to other
ipfs peers in the internet.
*/
class Swarm {
public class Swarm {
public List<MultiAddress> peers() throws IOException {
Map m = retrieveMap("swarm/peers?stream-channels=true");
return ((List<Object>)m.get("Strings")).stream().map(x -> new MultiAddress((String)x)).collect(Collectors.toList());
Expand All @@ -291,7 +291,7 @@ public Map disconnect(String multiAddr) throws IOException {
}
}

class Diag {
public class Diag {
public String net() throws IOException {
return new String(retrieve("diag/net?stream-channels=true"));
}
Expand All @@ -305,7 +305,7 @@ public Map id(String target) throws IOException {
return retrieveMap("id/" + target.toString());
}

class Stats {
public class Stats {
public Map bw() throws IOException {
return retrieveMap("stats/bw");
}
Expand All @@ -325,7 +325,7 @@ public Map log() throws IOException {
return retrieveMap("log/tail");
}

class Config {
public class Config {
public Map show() throws IOException {
return (Map)retrieveAndParse("config/show");
}
Expand All @@ -350,7 +350,7 @@ public Object update() throws IOException {
return retrieveAndParse("update");
}

class Update {
public class Update {
public Object check() throws IOException {
return retrieveAndParse("update/check");
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/ipfs/Multihash.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.*;

public class Multihash {
enum Type {
public enum Type {
sha1(0x11, 20),
sha2_256(0x12, 32),
sha2_512(0x13, 64),
Expand Down
4 changes: 3 additions & 1 deletion test/org/ipfs/Test.java → test/org/ipfs/test/Test.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.ipfs;
package org.ipfs.test;

import org.ipfs.*;

import java.io.*;
import java.util.*;
Expand Down

0 comments on commit a27ef5b

Please sign in to comment.