Skip to content

Commit a66cc93

Browse files
committed
doc: root CID clarification docs
Closes: #248
1 parent c730309 commit a66cc93

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [HTTP API](#http-api)
1414
* [Daemon Example](#daemon-example)
1515
* [Golang Library](#golang-library)
16+
* [Roots, pieces and payloads](#roots-pieces-and-payloads)
1617
* [Contribute](#contribute)
1718
* [License](#license)
1819

@@ -277,6 +278,12 @@ if err != nil {
277278

278279
The `Fetch` function takes a `context.Context`, a `*types.Request`, and a `*types.FetchOptions`. The `context.Context` is used to control the lifecycle of the fetch. The `*types.Request` is the fetch request we made above. The `*types.FetchOptions` is used to control the behavior of the fetch. The function returns a `*types.FetchStats` and an `error`. The `*types.FetchStats` is the fetch stats. The `error` is used to indicate if there was an error fetching the CID.
279280

281+
### Roots, pieces and payloads
282+
283+
Lassie uses the term **Root** to refer to the head block of a potential graph (DAG) of IPLD blocks. This is typically the block you request, using its CID, when you perform a _fetch_ with Lassie. Of course a root could also be a sub-root of a larger graph, but when performing a retrieval with Lassie, you are focusing on the graph underneath the block you are fetching, and considerations of larger DAGs are not relevant.
284+
285+
In the Filecoin ecosystem, there exists terminology related to "pieces" and "payloads" and there may be confusion between the way lassie uses the term "root CID" and some of the language used in Filecoin. A **Piece** is a Filecoin storage deal unit, typically containing user data organized into a CAR; then padded to size to form a portion of a Filecoin sector. Filecoin pieces have their own CIDs, and it is possible to retrieve a whole, raw piece, from Filecoin. This can lead to terminology such as "piece root CID". Lassie currently does not perform whole-piece retrievals, and is not intended to be able to handle piece CIDs. Additionally, in Filecoin the term **Payload** is sometimes used in reference to the IPLD data inside a piece when performing a storage or retrieval deal. This is closer to the way Lassie uses the term **Root** and historical Lassie code contains some references to "payloads" that are actually referring to the root CID of a graph.
286+
280287
## Contribute
281288

282289
Early days PRs are welcome!

pkg/types/request.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,21 @@ type RetrievalRequest struct {
8484
FixedPeers []peer.AddrInfo
8585
}
8686

87-
// NewRequestForPath creates a new RetrievalRequest from the provided parameters
88-
// and assigns a new RetrievalID to it.
87+
// NewRequestForPath creates a new RetrievalRequest for the given root CID as
88+
// the head of the graph to fetch, the path within that graph to fetch, the
89+
// scope that dictates the depth of fetching withint he graph and the byte
90+
// range to fetch if intending to fetch part of a large UnixFS file.
91+
//
92+
// The byteRange parameter should be left nil if this is not a request for a
93+
// partial UnixFS file; and if it is set, the dagScope should be DagScopeEntity.
8994
//
9095
// The LinkSystem is configured to use the provided store for both reading
9196
// and writing and it is explicitly set to be trusted (i.e. it will not
9297
// check CIDs match bytes). If the storage is not truested,
9398
// request.LinkSystem.TrustedStore should be set to false after this call.
9499
func NewRequestForPath(
95100
store ipldstorage.WritableStorage,
96-
cid cid.Cid,
101+
rootCid cid.Cid,
97102
path string,
98103
dagScope trustlessutils.DagScope,
99104
byteRange *trustlessutils.ByteRange,
@@ -114,7 +119,7 @@ func NewRequestForPath(
114119

115120
return RetrievalRequest{
116121
Request: trustlessutils.Request{
117-
Root: cid,
122+
Root: rootCid,
118123
Path: path,
119124
Scope: dagScope,
120125
Bytes: byteRange,

pkg/types/types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ func NewFetchConfig(opts ...FetchOption) FetchConfig {
4545
}
4646

4747
// RetrievalCandidate describes a peer and CID combination that can be used to
48-
// retrieve data from the peer. The Metadata field contains information about
49-
// the protocols supported by the peer that may be used to further refine
50-
// how the retrieval is performed.
48+
// retrieve data from the peer. The RootCid describes the head of an IPLD graph
49+
// that is being retrieved. The MinerPeer is the peer that is (apparently)
50+
// storing the data.
51+
//
52+
// The Metadata field contains information about the protocols supported by the
53+
// peer that may be used to further refine how the retrieval is performed.
5154
type RetrievalCandidate struct {
5255
MinerPeer peer.AddrInfo
5356
RootCid cid.Cid

0 commit comments

Comments
 (0)