readme.go 1.14 KB
Newer Older
1 2
package flatfs

tavit ohanian's avatar
tavit ohanian committed
3
var README_DMS3_DEF_SHARD = `This is a repository of IPLD objects. Each IPLD object is in a single file,
4 5 6 7 8 9
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
10
prefixes, we now use the next-to-last two characters.
11 12 13 14 15 16 17

    func NextToLast(base32cid string) {
      nextToLastLen := 2
      offset := len(base32cid) - nextToLastLen - 1
      return str[offset : offset+nextToLastLen]
    }

Kevin Atkinson's avatar
Kevin Atkinson committed
18 19 20 21 22
For example, an object with a base58 CIDv1 of

    zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f

has a base32 CIDv1 of
23 24 25

    BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA

Kevin Atkinson's avatar
Kevin Atkinson committed
26
and will be placed at
27 28 29 30 31 32 33

    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.
`