Advertisement
Guest User

Untitled

a guest
Nov 1st, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. If you want to host some content, like, barack_obama.html, you’ll need to add that file to your IPFS, like so:
  2. > ipfs add barack_obama.html
  3.  
  4. 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>”.
  5.  
  6. 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
  7. >ipfs add -r public
  8.  
  9. You’ll get a SHA-256 hash as the link to this directory, <public-hash>. Now publish this directory using IPNS:
  10. >ipfs name publish <public-hash>
  11.  
  12. 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:
  13.  
  14. “/ipns/<your-peer-id>/Barack_Obama”
  15.  
  16. 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.
  17.  
  18. 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:
  19. >ipfs add <tag-file>
  20.  
  21. Which will have the link <tag-hash>.
  22.  
  23. 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:
  24. > ipfs dht findprovs <tag-hash>
  25.  
  26. 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.
  27.  
  28. 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