IPNS - Publish a CID
See original GitHub issueHello, I’m currently trying to replicate the following behavior with java-ipfs-api:
Add a DAG node to IPFS
$ echo '{"name":"blogpost","documents":[]}'|ipfs dag put
zdpuAknRh1Kro2r2xBDKiXyTiwA3Nu5XcmvjRPA1VNjH41NF7
Publish the CID of the DAG Object to an IPNS namespace
$ ipfs name publish zdpuAknRh1Kro2r2xBDKiXyTiwA3Nu5XcmvjRPA1VNjH41NF7 --key=test-dag
Published to QmdCSru6FJRp3gYSuAcg64az6mkc7SXhSvEHry8aKUeMwu: /ipfs/zdpuAknRh1Kro2r2xBDKiXyTiwA3Nu5XcmvjRPA1VNjH41NF7
Resolve the IPNS namespace and get the DAG node
$ echo $(ipfs name resolve QmdCSru6FJRp3gYSuAcg64az6mkc7SXhSvEHry8aKUeMwu) | ipfs dag get
{"documents":[],"name":"blogpost"}
Using java-ipfs-api, I’m doing
- Running a go-ipfs node
$ ipfs daemon
- Executing the following code
@Test
public void issue() throws Exception {
try {
IPFS ipfs = new IPFS("localhost", 5001);
// JSON document
String json = "{\"name\":\"blogpost\",\"documents\":[]}";
log.info("json: {}", json);
// Add a DAG node to IPFS
MerkleNode merkleNode = ipfs.dag.put("json", json.getBytes());
log.info("store [json: {}] - {}", json, merkleNode.toJSON());
Assert.assertEquals("expected to be zdpuAknRh1Kro2r2xBDKiXyTiwA3Nu5XcmvjRPA1VNjH41NF7" , "zdpuAvQHo4UMMFvGiYJ5yptX4JFZtX77jz457ebwQiToG26TJ", merkleNode.hash.toString());
// Get a DAG node
byte[] res = ipfs.dag.get(Cid.buildCidV0(merkleNode.hash));
log.info("fetch({}): {}", merkleNode.hash.toString(), new String(res));
Assert.assertEquals("Should be equals", json, new String(res));
// Publish to IPNS
Map result = ipfs.name.publish(merkleNode.hash);
log.info("result {}", result);
// Resolve from IPNS
String resolved = ipfs.name.resolve(Multihash.fromBase58((String) result.get("Name")));
log.info("resolved {}", resolved);
Assert.assertEquals("Should be equals", resolved, merkleNode.hash.toBase58());
} catch(Exception e) {
log.error("Error", e);
throw e;
}
}
Unfortunately it failed on the IPNS publication ipfs.name.publish(merkleNode.hash)
09:55:01.578 [main] INFO TestIPNS - json: {"name":"blogpost","documents":[]}
09:55:01.606 [main] INFO TestIPNS - store [json: {"name":"blogpost","documents":[]}] - {Hash=zdpuAvQHo4UMMFvGiYJ5yptX4JFZtX77jz457ebwQiToG26TJ, Links=[], Size=34}
09:55:01.609 [main] INFO TestIPNS - fetch(zdpuAvQHo4UMMFvGiYJ5yptX4JFZtX77jz457ebwQiToG26TJ): {"name":"blogpost","documents":[]}
09:55:01.616 [main] ERROR TestIPNS - Error
java.lang.RuntimeException: IOException contacting IPFS daemon.
Trailer: [X-Stream-Error] {"Message":"unexpected EOF","Code":0,"Type":"error"}
at io.ipfs.api.IPFS.get(IPFS.java:592)
at io.ipfs.api.IPFS.retrieve(IPFS.java:571)
at io.ipfs.api.IPFS.retrieveAndParse(IPFS.java:553)
at io.ipfs.api.IPFS.retrieveMap(IPFS.java:549)
at io.ipfs.api.IPFS.access$200(IPFS.java:15)
at io.ipfs.api.IPFS$Name.publish(IPFS.java:361)
at io.ipfs.api.IPFS$Name.publish(IPFS.java:357)
at TestIPNS.issue(TestIPNS.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:5001/api/v0/name/publish?arg=/ipfs/zdpuAvQHo4UMMFvGiYJ5yptX4JFZtX77jz457ebwQiToG26TJ
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at io.ipfs.api.IPFS.get(IPFS.java:580)
... 30 common frames omitted
The IPFS daemon doesn’t log anything.
I acknowledge the issue might be related to the API itself and not the Java client directly. Still investigating…
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
IPNS (InterPlanetary Name System) and Mutability - IPFS Docs
Resolving IPNS names using IPFS gateways; Publishing IPNS names ... Changing a file changes its hash, and consequently its CID which is used...
Read more >IPNS - Publish a CID · Issue #77 · ipfs-shipyard/java ... - GitHub
Hello, I'm currently trying to replicate the following behavior with java-ipfs-api: Add a DAG node to IPFS $ echo '{"name":"blogpost" ...
Read more >IPFS Gateway
The InterPlanetary Name Service (IPNS) allows a version-independent IPNS identifier to resolve into the current version's IPFS CID.
Read more >Publish an object as IPNS name. | Guides | mborho/ipfs
Publish an object as IPNS name. terraform { required_providers { ipfs = { source = "mborho/ipfs" version = "=> 0.1.0" } } provider...
Read more >The definitive guide to publishing content on the decentralized ...
The definitive guide to publishing content on the decentralized web. Build a simple decentralized RESTful endpoint with minimal effort using ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
done
Hey, Thanks for fixing this, I just made a quick test and it works like a charm (except of course that IPNS publishing takes 2min, but that’s a protocol issue I believe).
What’s your Maven release process to get 1.2.1 on available publicly on jitpack ? Let me know if you need some input on Continuous Release management stuff using Maven, Github and Travis.
Closing the issue!