You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documentation/pinning.md
+134-7Lines changed: 134 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,141 @@ slug: /pinning
5
5
sidebar_label: Pinning
6
6
---
7
7
8
-
## 🚧 Under Construction 🚧
9
-
:::caution 🚧 This page is under construction
8
+
Pinning allows you to guarantee that your uploaded content will always be available by storing it **locally on your own Bee node**. However, pinning **guarantee availability across the Swarm network**. Therefore you must use pinning along with the **stewardship utilities** included in `bee-js` to monitor the availability of your pinned content and reupload it if needed.
10
9
11
-
This section is still being worked on. Check back soon for updates!
10
+
In this section, you'll learn how to:
12
11
13
-
:::
12
+
- Pin content
13
+
- Check whether pinned content is still retrievable from the network
14
+
- Reupload missing content
15
+
- View all currently pinned references
16
+
- Remove pins that are no longer required
17
+
18
+
19
+
20
+
## Pinning and Unpinning Content
21
+
22
+
To pin a reference (so it remains stored on your node):
23
+
24
+
```js
25
+
awaitbee.pin(reference)
26
+
console.log('Reference pinned locally.')
27
+
```
28
+
29
+
To stop tracking and remove it from local pin storage:
30
+
31
+
```js
32
+
awaitbee.unpin(reference)
33
+
console.log('Reference unpinned and no longer tracked.')
34
+
```
35
+
36
+
37
+
## Checking if a Reference is Retrievable
38
+
39
+
Use `isReferenceRetrievable(reference)` to verify if the content for a given Swarm reference is currently accessible on the network:
Once you’re done tracking an upload, you can delete the tag to keep your node clean:
79
+
80
+
```js
81
+
awaitbee.deleteTag(tag.uid)
82
+
console.log("Deleted tag:", tag.uid)
83
+
```
84
+
85
+
86
+
## Example Script
87
+
88
+
The following script automates the process of checking all locally pinned references, verifying their retrievability from the network, and reuploading any that are missing. This ensures that your pinned data remains available even if it has dropped out of the Swarm network.
You can track the progress of your uploads using "tags". Each tag tracks how many chunks were **split**, **stored**, **seen**, and **synced** by the network. By creating a tag before uploading and passing it to the upload function, you make the upload *trackable, allowing you to confirm whether your uploaded data has been fully synced.
9
+
10
+
## How It Works
11
+
12
+
### 1. Create a Tag
13
+
14
+
Before uploading, create a new tag using `bee.createTag()`. This returns a unique tag UID that will be used to monitor the upload.
15
+
16
+
```js
17
+
consttag=awaitbee.createTag()
18
+
console.log("Created new tag with UID:", tag.uid)
19
+
```
20
+
21
+
Alternatively, you can use an existing tag from `bee.getAllTags()` (useful for testing or reuse):
22
+
23
+
```js
24
+
constallTags=awaitbee.getAllTags()
25
+
if (allTags.length>0) {
26
+
tag = allTags[0]
27
+
console.log("Using existing tag with UID:", tag.uid)
28
+
}
29
+
```
30
+
31
+
### 2. Upload a File with the Tag
32
+
33
+
To enable tracking, pass the tag UID into the upload options under the `tag` key:
This links the upload to your tag so you can monitor its progress.
43
+
44
+
### 3. Track Tag Progress
45
+
46
+
Use `bee.retrieveTag(tagUid)` to check how many chunks have been split and how many are synced. Poll repeatedly until `synced === split` to know when the upload has fully propagated.
0 commit comments