ipfs / go-ipld-format

IPLD Node and Resolver interfaces in Go
https://github.com/ipld/ipld
MIT License
64 stars 26 forks source link

Move Size() elsewhere #12

Open Stebalien opened 7 years ago

Stebalien commented 7 years ago

By case:

  1. In CBOR encoded IPLD nodes, it means "size of this encoded node" (property of Block).
  2. In protobuf IPFS nodes, it means "size of this encoded node + size of all encoded children" (property of IPFSNode because only IPFSNode links store enough metadata to efficiently compute this).

Therefore, it doesn't belong on Node.

  1. Define Size on Block that returns the size of the encoded block case 1. Note: This size method should not be able to return an error.
  2. Define some form of FileSize/IPFSDagSize on an IPFSNode type (elsewhere) for case 2.