Skip to content

Commit 01d7e07

Browse files
committed
tweaks
1 parent 8fdd04c commit 01d7e07

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

docs/develop/manifests.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,29 @@ To work with them, these bytes must be [**unmarshalled** (decoded)](https://en.w
3636

3737
`bee-js` provides this functionality through the `MantarayNode.umarshal` method.
3838

39-
After unmarshalling, the data is still quite low-level (for example, many fields are `Uint8Array` values) and usually needs additional processing to make it human-readable. You can find a [script for this in the `ethersphere/examples` repo](https://github.com/ethersphere/examples/blob/main/manifests/manifestToJson.js).
39+
After unmarshalling, the data is still quite low-level (for example, many fields are `Uint8Array` values) and usually needs additional processing to make it human-readable. You can find a [script for this in the `ethersphere/examples` repo](https://github.com/ethersphere/examples/blob/main/manifests/manifestToJson.js).
4040
:::
4141

4242
## Introduction to Manifests
4343

44-
Whenever you upload a folder using Bee’s `/bzz` endpoint (and tools built on top of it such as `bee-js` and `swarm-cli`), Bee automatically creates a manifest that records:
44+
Whenever you upload a folder using Bee’s [`/bzz` endpoint](https://docs.ethswarm.org/api/#tag/BZZ) (and tools built on top of it such as `bee-js` and `swarm-cli`), Bee automatically creates a manifest that records:
4545

4646
- every file inside the folder
4747
- the file’s relative path
4848
- metadata (content type, filename, etc.)
49-
- optional website metadata (index document, error document)
49+
- optional website metadata ([index document, error document](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post))
5050

5151
Uploads made through the Bee API using `/bytes` or `/chunks` **do not** create manifests.
52-
However, most developers rarely use these endpoints directly unless they’re building for some custom use-case.
52+
53+
However, these endpoints are typically used only for custom use cases requiring lower level control, and are not required for standard use cases such as storing and retrieving files and hosting websites or dapps.
5354

5455
Because `bee-js` and `swarm-cli` call `/bzz` when appropriate, **you get a manifest automatically** whenever you upload a directory.
5556

56-
:::important
57+
:::info
5758
Although working with a manifest may _feel_ like moving or deleting files in a regular filesystem, **no data on Swarm is ever changed**, because all content is immutable.
5859

5960
When you "modify" a manifest, you’re actually creating a _new_ manifest based on the previous one.
61+
6062
Removing an entry only removes it from the manifest — the underlying file remains available as long as its postage batch is valid.
6163
:::
6264

@@ -71,7 +73,7 @@ are also excellent references.
7173

7274
## Manifest Structure Explained
7375

74-
The printed output below shows a **decoded Mantaray manifest** (printed using the `printManifestJson` method from the [`manifestToJson.js` script in the examples repo](https://github.com/ethersphere/examples/blob/main/manifests/manifestToJson.js)), represented as a tree of nodes and forks. Each part plays a specific role in describing how file paths map to Swarm content. Here’s what each piece means.
76+
The printed output below shows a **decoded Mantaray manifest** (printed using the `printManifestJson` method from the [`manifestToJson.js` script in the examples repo](https://github.com/ethersphere/examples/blob/main/manifests/manifestToJson.js)), represented as a tree of nodes and forks. Each part plays a specific role in describing how file paths map to Swarm content:
7577

7678
```json
7779
{
@@ -118,6 +120,8 @@ The printed output below shows a **decoded Mantaray manifest** (printed using th
118120

119121
```
120122

123+
Here’s what each piece means:
124+
121125
#### **Node:**
122126

123127
A **Node** represents a position within the manifest trie.
@@ -137,7 +141,7 @@ Every node may contain:
137141

138142
#### **Forks:**
139143

140-
A **fork** is an edge from one node to another.
144+
A **fork** is an [edge](https://en.wikipedia.org/wiki/Glossary_of_graph_theory#edge) from one node to another.
141145
It is how the trie branches when file paths diverge.
142146

143147
For example, under `folder/`, you see:
@@ -153,7 +157,7 @@ This means:
153157
- the `folder/` node has two children
154158
- those children represent different path continuations (i.e., different files)
155159

156-
Forks are how shared prefixes are stored only once. Everything that starts with `"folder/"` branches from the same node.
160+
Forks are how shared prefixes are stored only once. Everything that starts with `folder/` branches from the same node.
157161

158162
#### **Path:**
159163

@@ -193,7 +197,7 @@ For example:
193197
- The node for `folder/` also has no file associated → target is zero.
194198
It is just an internal directory-like prefix.
195199

196-
Only **leaf nodes**, where a file actually exists, have a non-zero target (the file’s Swarm reference).
200+
Only [**leaf nodes**](https://en.wikipedia.org/wiki/Glossary_of_graph_theory#leaf) where a file actually exists, have a non-zero target (the file’s Swarm reference).
197201

198202
So:
199203

@@ -205,7 +209,7 @@ So:
205209

206210
:::warning
207211
The `target` field in a manifest points to the raw file root chunk, not a manifest. `bee-js` and `swarm-cli` file download functions expect a file manifest, even for single-file uploads, so downloading using the raw target hash will not work properly.
208-
Instead, download files by using the top-level directory manifest and the file’s path within it.
212+
Instead, download files by using the top-level directory root manifest plus the file path relative to the root hash as it is represented in the manifest trie.
209213

210214
Example:
211215

@@ -265,9 +269,9 @@ This means:
265269

266270
Meanwhile, `"folder/"` has **no file itself**, so its target is zero.
267271

268-
## Manipulating Directories
272+
## Usage & Example Scripts
269273

270-
In this section we explain how to inspect and modify manifests for non-website directories. You can find the completed [example scripts on GitHub](https://github.com/ethersphere/examples/tree/main/manifests).
274+
In this section we explain how to inspect and modify manifests for non-website directories. You can find the completed [example scripts on GitHub](https://github.com/ethersphere/examples/tree/main/manifests/directory).
271275

272276
In the following guides we will explain how to:
273277

@@ -326,7 +330,7 @@ POSTAGE_BATCH_ID=<BATCH_ID>
326330

327331
Great! Now you're all set up and ready to go.
328332

329-
### Uploading a Directory and Printing Its Manifest
333+
### Uploading and Printing
330334

331335
In our first script, we will simply upload our sample directory and print its contents:
332336

@@ -464,7 +468,7 @@ Manifest reference: 4d5e6e3eb532131e128b1cd0400ca249f1a6ce5d4005c0b57bf848131300
464468
465469
We will use this in the next section when adding a file manually to the manifest.
466470
467-
### Adding a New File to the Manifest
471+
### Adding a New File
468472
469473
This script uploads a **new file** (e.g. `newfile.txt`) and then updates the existing manifest so the new file becomes part of the directory structure.
470474
@@ -589,7 +593,7 @@ new.txt: Hi, I'm new here.
589593
590594
This produces a new manifest where `/new.txt` is now accessible as a root level entry.
591595
592-
### Moving a File to a Subfolder
596+
### Moving a File
593597
594598
This script:
595599
@@ -738,4 +742,3 @@ Now the file appears under:
738742
739743
Note that the only new method we used was `node.removeFork()` to remove the entry from the manifest.
740744
741-

0 commit comments

Comments
 (0)