Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you want to host some content, like, barack_obama.html, you’ll need to add that file to your IPFS, like so:
- > ipfs add barack_obama.html
- This will give you the SHA-256 hash of barack_obama.html, we’ll call it <obama-hash>, which is the IPFS link to your file. Your file can now be found at “/ipfs/<obama-hash>”.
- Now, if you want to update barack_obama.html, this will force the SHA-256 hash to change, that means your link has to change. To avoid this issue we have to use IPNS, the “InterPlanetary Name Space”. Rename your barack_obama.html file to Barack_Obama and place it into a directory called ‘public’ (or some other name). Now add this directory to IPFS like so
- >ipfs add -r public
- You’ll get a SHA-256 hash as the link to this directory, <public-hash>. Now publish this directory using IPNS:
- >ipfs name publish <public-hash>
- What this does is bind your IPFS peer-id to some IPFS link, so that when somebody tries to access “/ipns/<your-peer-id>”, this will resolve to “/ipfs/<your-ipfs-link>”. So, now when somebody wants to access your content about Obama, they can always visit the same link to find it:
- “/ipns/<your-peer-id>/Barack_Obama”
- If you need to modify something in your Barack_Obama file, you can do that and repeat the steps above and your modifications will be available at that same link.
- Now you’re hosting content and you’ve got URL permanence, great. Now, how do users know that you’re hosting content? Make a file containing just the text “/ipfs-wiki/Barack_Obama”, let’s call it <tag-file>. Now add this to IPFS like so:
- >ipfs add <tag-file>
- Which will have the link <tag-hash>.
- Now anybody who wants to find out if somebody’s hosting some content by the title Barack_Obama, then they can take the SHA-256 hash of “/ipfs-wiki/Barack_Obama”, which will be equal to <tag-hash>, because it’s the same SHA-256 function on the same input file. So now they can run:
- > ipfs dht findprovs <tag-hash>
- They will get a list of the peer-ids of everybody you can find who hosts the file containing the <tag-file>. If they found you, then your peer-id will be on this list. So now they know they can attempt to access that content from you at “/ipns/<your-peer-id>/Barack_Obama”. Other people might host different content with the same title, but there is not necessarily conflict because the user can see all the different options, including yours.
- Cool, now we have a mechanism to find and provide content and create a decentralized Wikipedia, but it’s kind of clunky, so we’ll want to make this whole process easier by automating it and putting it behind a nice user interface, as well as standardize certain formats and protocols to allow smoother integration of content between users.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement