Skip to content

Instantly share code, notes, and snippets.

@kevina

kevina/README Secret

Created December 22, 2016 00:40
Show Gist options
  • Save kevina/e217dd4c763aaaafdab9657935920da5 to your computer and use it in GitHub Desktop.
Save kevina/e217dd4c763aaaafdab9657935920da5 to your computer and use it in GitHub Desktop.
Repo README
This is a repository of IPLD objects. Each IPLD object is in a single file,
named <base32 encoding of cid>.data. Where <base32 encoding of cid> is the
"base32" encoding of the CID (as specified in
https://github.com/multiformats/multibase) without the 'B' prefix.
All the object files are placed in a tree of directories, based on a
function of the CID. This is a form of sharding similar to
the objects directory in git repositories. Previously, we used
prefixes, we now use the next-to-last two charters.
func NextToLast(base32cid string) {
nextToLastLen := 2
offset := len(base32cid) - nextToLastLen - 1
return str[offset : offset+nextToLastLen]
}
For example, an object with a CIDv1 of
BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA
Will be placed at
SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data
with 'SC' being the last-to-next two characters and the 'B' at the
beginning of the CIDv1 string is the multibase prefix that is not
stored in the filename.
@whyrusleeping
Copy link

In the example section, could we show the base58 version of the cid, and then say "this translates to this in base32, with the multibase prefix removed", just to make it easier for the user to go from what they see on the CLI to what they see on the filesystem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment