-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ProtoSchool #5
Comments
Part 1 - Basic Content Addressinghttps://proto.school/#/basics/01https://proto.school/#/basics/02https://proto.school/#/basics/03Part 2 - Bloghttps://proto.school/#/blog/01https://proto.school/#/blog/02Exercise instructs learner to open Dev Tools: Latest Google Chrome Browser. Thousands of errors. not very confidence inspiring ... 🙄 I'm not "phased" by these errors, but a beginner definitely would be. CIDs in dev tools console before making updates: CIDs in dev tools console after adding the OK, this is a curiosity thing to understand how the
And the corresponding CIDs are:
What if we change the order of the keys and data to:
CIDs are identical if after re-ordering the fields and the "tags" in the first blog post. ✅
This is a good sign because the content hasn't changed, just the order of the key:value in the Object. 👍 https://proto.school/#/blog/03This time the order is a deciding factor in the resulting CID ... 🙄 Solution:
https://proto.school/#/blog/04The lesson in which the "DAG" acronym is finally expanded: DAG (Directed Acyclic Graph) solution: // Add your code here
const dogsPostCid = await ipfs.dag.put({
content: "dogs",
author: {"/": samCid.toBaseEncodedString()},
tags: ["funny", "hobby"]
})
const hobbyTagCid = await ipfs.dag.put({
tag: "hobby",
posts: [
{"/": treePostCid.toBaseEncodedString()},
{"/": computerPostCid.toBaseEncodedString()},
{"/": dogsPostCid.toBaseEncodedString()},
]
})
const funnyTagCid = await ipfs.dag.put({
tag: "funny",
posts: [
{"/": dogsPostCid.toBaseEncodedString()}
]
})
return dogsPostCid; https://proto.school/#/blog/05Step 5: Add the code I added proactively above ... Solution:
https://proto.school/#/blog/06 - List posts chronologically with a chain of linksThis exercise is pretty massive ...: Fail: (I don't understand why the https://proto.school/#/blog/07 - Traverse through all postsHit a "brick wall" trying to implement the
This is basically Game Over. Calling it a day. |
BEFORE: (trying too hard...) // I added a second "list" parameter so I could write the function recursively ...
const traversePosts = async (cid, list = []) => {
console.log('cid', cid)
// Your code goes here
list.push(new CID(cid.multihash));
console.log(list);
if(list.length === 3) { return list };
let pcid, pCID;
try {
pcid = await ipfs.dag.get(cid);
console.log('pcid', pcid)
if(pcid && pcid.value && pcid.value.prev && pcid.value.prev['/']) {
pCID = new CID((pcid).value.prev['/'])
console.log('pCID', pCID)
traversePosts(pCID, list);
} else {
console.log(list);
console.log('return!!')
return list;
}
} catch (e) {
console.log('not a valid cid');
console.log(list);
console.log('return!!')
return list;
}
} AFTER: using a const traversePosts = async (cid) => {
let list = [];
while (cid) {
list.push(cid)
const got = await ipfs.dag.get(cid)
const prev = got.value.prev
if (prev) {
cid = new CID(prev['/'])
} else {
return list
}
}
} Can't say that was a very beginner friendly experience ... 😕 |
Opened issue: ProtoSchool/protoschool.github.io#96 to inform creators of difficulty. |
@alanshaw, where should I go next to continue my IPFS learning quest? 🤔 |
This is super good feedback for the protoschool team thank you for documenting ❤️ It's worth checking out the examples:
I can't remember if I told you about https://awesome.ipfs.io/ I have some fun videos you can watch: |
@alanshaw thanks for the links and encouragement. 👍 Hope all is well in JailMake Land. ☀️ |
We have a discussion place here https://discuss.ipfs.io/ We are on IRC #ipfs on freenode |
@alanshaw thanks looks like I have a bit of reading to do ... https://discuss.ipfs.io/top 👍 |
In light of @terichadbourne's comment on ProtoSchool/protoschool.github.io#96 (comment) I'm going to go through the https://proto.school from scratch again with "shoshin" ... 🤓 |
No change to home page: https://proto.school https://proto.school/#/basics/01https://proto.school/#/basics/02I already knew how to link one item of content to another: const run = async () => {
let cid = await ipfs.dag.put({test: 1})
return await ipfs.dag.put({ bar: {"/": cid } })
} So I was able to "pass" this exercise:
So we no longer need to have the https://proto.school/#/basics/03Relevant line of code to make this exercise pass: return ipfs.dag.get(cid2, '/bar/test') ... on to the next one ... https://proto.school/#/blog/01The way of linking to related content is much better! 🎉 https://proto.school/#/blog/02https://proto.school/#/blog/03Solution: // Add your code here
const hobbyTags = await ipfs.dag.put({
tag: "hobby",
posts: [
treePostCid,
computerPostCid
]
})
const outdoorTags = await ipfs.dag.put({
tag: "outdoor",
posts: [
treePostCid
]
})
return [hobbyTags, outdoorTags] https://proto.school/#/blog/04Solution: const dogPostCid = await ipfs.dag.put({
content: "dogs",
author: samCid,
tags: ["funny", "hobby"]
}) https://proto.school/#/blog/05Solution: // Add your new code here and modify the tags above
const funnyTagCid = await ipfs.dag.put({
tag: "funny",
posts: [ dogPostCid ]
})
return [funnyTagCid, hobbyTagCid, outdoorTagCid] https://proto.school/#/blog/06Pretty straightforward: // Modify the blog posts below
const treePostCid = await ipfs.dag.put({
content: "trees",
author: samCid,
tags: ["outdoor", "hobby"]
})
const computerPostCid = await ipfs.dag.put({
content: "computers",
author: natCid,
tags: ["hobby"],
prev: treePostCid
})
const dogPostCid = await ipfs.dag.put({
content: "dogs",
author: samCid,
tags: ["funny", "hobby"],
prev: computerPostCid
})
const outdoorTagCid = await ipfs.dag.put({
tag: "outdoor",
posts: [ treePostCid ]
})
const hobbyTagCid = await ipfs.dag.put({
tag: "hobby",
posts: [ treePostCid, computerPostCid, dogPostCid ]
})
const funnyTagCid = await ipfs.dag.put({
tag: "funny",
posts: [ dogPostCid ]
})
return dogPostCid https://proto.school/#/blog/07Solution: const traversePosts = async (cid) => {
let list = [];
while (cid) {
list.push(cid);
cid = (await ipfs.dag.get(cid)).value.prev
}
return list;
} Second time round it was much easier. |
@nelsonic I'm glad you liked the new link API and found the instructions more clear this time! A couple of questions out of curiosity if you have a sec:
|
@terichadbourne I did not notice the It's definitely there, I just didn't see it. Other beginners will. ✅ The UI on the home page displays a "checkmark" whenever a lesson is complete: The code editor seems really slick! noticed auto-saving, syntax checking and error notification. Thanks again! |
@nelsonic Glad you noticed the code caching and the status indicator about whether you've completed a lesson. There are npm packages called |
@terichadbourne nice work! 🎉 Note-to-self: https://microsoft.github.io/monaco-editor |
https://proto.school
thanks to @alanshaw for sharing this!
It's Next on my "to learn" list. 🤓
The text was updated successfully, but these errors were encountered: