hypercore 10.0.0-alpha.1 → 10.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test-node.yml +1 -2
- package/README.md +17 -1
- package/__snapshots__/test/storage.js.snapshot.cjs +15 -0
- package/index.js +135 -34
- package/lib/bitfield.js +3 -2
- package/lib/block-encryption.js +68 -0
- package/lib/block-store.js +3 -1
- package/lib/core.js +3 -1
- package/lib/merkle-tree.js +43 -29
- package/lib/oplog.js +4 -3
- package/lib/protocol.js +9 -6
- package/lib/replicator.js +60 -15
- package/package.json +6 -4
- package/test/basic.js +12 -0
- package/test/encryption.js +123 -0
- package/test/replicate.js +76 -0
- package/test/storage.js +31 -0
package/README.md
CHANGED
|
@@ -63,7 +63,8 @@ Note that `tree`, `data`, and `bitfield` are normally heavily sparse files.
|
|
|
63
63
|
createIfMissing: true, // create a new Hypercore key pair if none was present in storage
|
|
64
64
|
overwrite: false, // overwrite any old Hypercore that might already exist
|
|
65
65
|
valueEncoding: 'json' | 'utf-8' | 'binary', // defaults to binary
|
|
66
|
-
keyPair: kp // optionally pass the public key and secret key as a key pair
|
|
66
|
+
keyPair: kp, // optionally pass the public key and secret key as a key pair
|
|
67
|
+
encryptionKey: k // optionally pass an encryption key to enable block encryption
|
|
67
68
|
}
|
|
68
69
|
```
|
|
69
70
|
|
|
@@ -113,6 +114,7 @@ A range can have the following properties:
|
|
|
113
114
|
{
|
|
114
115
|
start: startIndex,
|
|
115
116
|
end: nonInclusiveEndIndex,
|
|
117
|
+
blocks: [index1, index2, ...],
|
|
116
118
|
linear: false // download range linearly and not randomly
|
|
117
119
|
}
|
|
118
120
|
```
|
|
@@ -125,6 +127,12 @@ To download the full core continously (often referred to as non sparse mode) do
|
|
|
125
127
|
core.download({ start: 0, end: -1 })
|
|
126
128
|
```
|
|
127
129
|
|
|
130
|
+
To downloaded a discrete range of blocks pass a list of indices.
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
core.download({ blocks: [4, 9, 7] });
|
|
134
|
+
```
|
|
135
|
+
|
|
128
136
|
To cancel downloading a range simply destroy the range instance.
|
|
129
137
|
|
|
130
138
|
``` js
|
|
@@ -195,6 +203,10 @@ In contrast to `core.key` this key does not allow you to verify the data but can
|
|
|
195
203
|
|
|
196
204
|
Populated after `ready` has been emitted. Will be `null` before the event.
|
|
197
205
|
|
|
206
|
+
#### `core.encryptionKey`
|
|
207
|
+
|
|
208
|
+
Buffer containing the optional block encryption key of this core. Will be `null` unless block encryption is enabled.
|
|
209
|
+
|
|
198
210
|
#### `core.length`
|
|
199
211
|
|
|
200
212
|
How many blocks of data are available on this core?
|
|
@@ -213,6 +225,10 @@ What is the current fork id of this core?
|
|
|
213
225
|
|
|
214
226
|
Populated after `ready` has been emitted. Will be `0` before the event.
|
|
215
227
|
|
|
228
|
+
#### `core.padding`
|
|
229
|
+
|
|
230
|
+
How much padding is applied to each block of this core? Will be `0` unless block encryption is enabled.
|
|
231
|
+
|
|
216
232
|
#### `const stream = core.replicate(isInitiatorOrReplicationStream)`
|
|
217
233
|
|
|
218
234
|
Create a replication stream. You should pipe this to another Hypercore instance.
|