Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: ipns publish example #3207

Merged
merged 26 commits into from
Sep 2, 2020
Merged

feat: ipns publish example #3207

merged 26 commits into from
Sep 2, 2020

Conversation

achingbrain
Copy link
Member

This follows on from @DougAnderson444's great work in #3166 (I can't push commits to his fork).

I've tided up the test and the instructions, but it doesn't always work reliably for me.

When I hit Publish to IPNS, quite frequently the IPNS name is resolved to the empty directory CID:

// browser console
Publish to IPNS
Initial Resolve QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
Subscribing to /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
12:32:47 Message c6b2c0951cba22d8 from QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
#1) Topic: /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
Value: /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
12:32:48 Message 5dc88986550867ea from QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
#2) Topic: /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
Value: /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
Publishing /ipfs/Qmd938ZvbdDBaHGFY5QC2VFesRrj4wnszwpiT3pQ6vGati to self /ipns/QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
12:32:50 Message 3866650046515a58 from QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
#3) Topic: /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
Value: /ipfs/Qmd938ZvbdDBaHGFY5QC2VFesRrj4wnszwpiT3pQ6vGati
Published QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf to /ipfs/Qmd938ZvbdDBaHGFY5QC2VFesRrj4wnszwpiT3pQ6vGati
Wait 5 seconds, then resolve...
Try resolve QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf on server through API
Resolved: /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
Error, resolve did not match /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn !== /ipfs/Qmd938ZvbdDBaHGFY5QC2VFesRrj4wnszwpiT3pQ6vGati
// server console
Subscribing to /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
12:32:47 Message c6b2c0951cba22d8 from QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
#1) Topic: /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
Value: /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
12:32:48 Message 5dc88986550867ea from QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
#2) Topic: /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
Value: /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
[Pass] Pubsub.ls
[Pass] Name.Pubsub.subs
12:32:50 Message 3866650046515a58 from QmPnx5euUoR7mHU3nf29tcRn5yCb1X7r6QHRTS9RpT13Wf
#3) Topic: /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA
Value: /ipfs/Qmd938ZvbdDBaHGFY5QC2VFesRrj4wnszwpiT3pQ6vGati
Subscribing to /record/L2lwbnMvEiAVmG4UEkG8Obk4CpyfVwRhS14ou8rQbCiIZqWDKrtEAA

If I then press Publish to IPNS again, it works and the test completes (assuming it hasn't timed out by then).

@vasco-santos any ideas why you have to publish twice?

@DougAnderson444
Copy link
Contributor

Thanks for the help with the test, it's helped me learn how to write them.

I noticed the empty directory CID too, could not figure out why it's happening. I originally thought it was related to missing {stream: false} but then I saw that @jacobheun found a bug in js http client streaming can't be overridden, which may be contributing to the issue?

@achingbrain
Copy link
Member Author

No, generally you want streaming, it just means you get results as they come in rather than waiting for them all to arrive first.

This PR has that fix applied anyway so I don't think it's related.

@vasco-santos
Copy link
Member

So, when IPFS is inited, we initializeKeyspace, which points to an empty directory:

Taking this in mind, it seems that the first name.publish did not finish before the resolve, or somehow it is running before init finishes.

@achingbrain achingbrain merged commit 91faec6 into master Sep 2, 2020
@achingbrain achingbrain deleted the feat/ipns-example branch September 2, 2020 15:34
SgtPooki referenced this pull request in ipfs/js-kubo-rpc-client Aug 18, 2022
This is an example for the /examples/ folder for how to `ipfs.name.publish` in `js-ipfs` and have that ipns record pubsub'd over to a friendly neighborhood `go-ipfs` node to get recorded on the `DHT`.

Co-authored-by: DougA <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/author-input Needs input from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants