hypercore 9.12.0 → 10.0.0-alpha.11
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 +3 -4
- package/README.md +131 -404
- package/__snapshots__/test/storage.js.snapshot.cjs +15 -0
- package/examples/announce.js +19 -0
- package/examples/basic.js +10 -0
- package/examples/http.js +123 -0
- package/examples/lookup.js +20 -0
- package/index.js +365 -1600
- package/lib/bitfield.js +113 -285
- package/lib/block-encryption.js +68 -0
- package/lib/block-store.js +58 -0
- package/lib/core.js +468 -0
- package/lib/extensions.js +76 -0
- package/lib/merkle-tree.js +1110 -0
- package/lib/messages.js +571 -0
- package/lib/mutex.js +39 -0
- package/lib/oplog.js +224 -0
- package/lib/protocol.js +525 -0
- package/lib/random-iterator.js +46 -0
- package/lib/remote-bitfield.js +24 -0
- package/lib/replicator.js +857 -0
- package/lib/streams.js +39 -0
- package/package.json +44 -45
- package/test/basic.js +59 -471
- package/test/bitfield.js +48 -133
- package/test/core.js +290 -0
- package/test/encodings.js +18 -0
- package/test/encryption.js +123 -0
- package/test/extension.js +71 -0
- package/test/helpers/index.js +23 -0
- package/test/merkle-tree.js +518 -0
- package/test/mutex.js +137 -0
- package/test/oplog.js +399 -0
- package/test/preload.js +72 -0
- package/test/replicate.js +227 -824
- package/test/sessions.js +173 -0
- package/test/storage.js +31 -0
- package/test/streams.js +39 -146
- package/test/user-data.js +47 -0
- package/bench/all.sh +0 -65
- package/bench/copy-64kb-blocks.js +0 -51
- package/bench/helpers/read-throttled.js +0 -27
- package/bench/helpers/read.js +0 -47
- package/bench/helpers/write.js +0 -29
- package/bench/read-16kb-blocks-proof-throttled.js +0 -1
- package/bench/read-16kb-blocks-proof.js +0 -1
- package/bench/read-16kb-blocks-throttled.js +0 -1
- package/bench/read-16kb-blocks.js +0 -1
- package/bench/read-512b-blocks.js +0 -1
- package/bench/read-64kb-blocks-linear-batch.js +0 -18
- package/bench/read-64kb-blocks-linear.js +0 -18
- package/bench/read-64kb-blocks-proof.js +0 -1
- package/bench/read-64kb-blocks.js +0 -1
- package/bench/replicate-16kb-blocks.js +0 -19
- package/bench/replicate-64kb-blocks.js +0 -19
- package/bench/write-16kb-blocks.js +0 -1
- package/bench/write-512b-blocks.js +0 -1
- package/bench/write-64kb-blocks-static.js +0 -1
- package/bench/write-64kb-blocks.js +0 -1
- package/example.js +0 -23
- package/lib/cache.js +0 -26
- package/lib/crypto.js +0 -5
- package/lib/replicate.js +0 -829
- package/lib/safe-buffer-equals.js +0 -6
- package/lib/storage.js +0 -421
- package/lib/tree-index.js +0 -183
- package/test/ack.js +0 -306
- package/test/audit.js +0 -36
- package/test/cache.js +0 -93
- package/test/compat.js +0 -209
- package/test/copy.js +0 -377
- package/test/default-storage.js +0 -51
- package/test/extensions.js +0 -137
- package/test/get.js +0 -64
- package/test/head.js +0 -65
- package/test/helpers/create-tracking-ram.js +0 -27
- package/test/helpers/create.js +0 -6
- package/test/helpers/replicate.js +0 -4
- package/test/seek.js +0 -234
- package/test/selections.js +0 -95
- package/test/set-uploading-downloading.js +0 -91
- package/test/stats.js +0 -77
- package/test/timeouts.js +0 -22
- package/test/tree-index.js +0 -841
- package/test/update.js +0 -156
- package/test/value-encoding.js +0 -52
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var path = require('path')
|
|
2
|
-
var hypercore = require('../')
|
|
3
|
-
|
|
4
|
-
var feed = hypercore(path.join(__dirname, 'cores/64kb'))
|
|
5
|
-
|
|
6
|
-
var then = Date.now()
|
|
7
|
-
var size = 0
|
|
8
|
-
var cnt = 0
|
|
9
|
-
|
|
10
|
-
feed.createReadStream({ batch: 100 })
|
|
11
|
-
.on('data', function (data) {
|
|
12
|
-
size += data.length
|
|
13
|
-
cnt++
|
|
14
|
-
})
|
|
15
|
-
.on('end', function () {
|
|
16
|
-
console.log(Math.floor(1000 * size / (Date.now() - then)) + ' bytes/s')
|
|
17
|
-
console.log(Math.floor(1000 * cnt / (Date.now() - then)) + ' blocks/s')
|
|
18
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var path = require('path')
|
|
2
|
-
var hypercore = require('../')
|
|
3
|
-
|
|
4
|
-
var feed = hypercore(path.join(__dirname, 'cores/64kb'))
|
|
5
|
-
|
|
6
|
-
var then = Date.now()
|
|
7
|
-
var size = 0
|
|
8
|
-
var cnt = 0
|
|
9
|
-
|
|
10
|
-
feed.createReadStream()
|
|
11
|
-
.on('data', function (data) {
|
|
12
|
-
size += data.length
|
|
13
|
-
cnt++
|
|
14
|
-
})
|
|
15
|
-
.on('end', function () {
|
|
16
|
-
console.log(Math.floor(1000 * size / (Date.now() - then)) + ' bytes/s')
|
|
17
|
-
console.log(Math.floor(1000 * cnt / (Date.now() - then)) + ' blocks/s')
|
|
18
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./helpers/read')('64kb', true)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./helpers/read')('64kb')
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var hypercore = require('../')
|
|
2
|
-
var path = require('path')
|
|
3
|
-
|
|
4
|
-
var source = hypercore(path.join(__dirname, 'cores/16kb'))
|
|
5
|
-
|
|
6
|
-
source.ready(function () {
|
|
7
|
-
var dest = hypercore(path.join(__dirname, 'cores/16kb-copy'), source.key, { overwrite: true })
|
|
8
|
-
var then = Date.now()
|
|
9
|
-
|
|
10
|
-
replicate(source, dest).on('end', function () {
|
|
11
|
-
console.log(Math.floor(1000 * dest.byteLength / (Date.now() - then)) + ' bytes/s')
|
|
12
|
-
console.log(Math.floor(1000 * dest.length / (Date.now() - then)) + ' blocks/s')
|
|
13
|
-
})
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
function replicate (a, b) {
|
|
17
|
-
var s = a.replicate(false)
|
|
18
|
-
return s.pipe(b.replicate(true)).pipe(s)
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var hypercore = require('../')
|
|
2
|
-
var path = require('path')
|
|
3
|
-
|
|
4
|
-
var source = hypercore(path.join(__dirname, 'cores/64kb'))
|
|
5
|
-
|
|
6
|
-
source.ready(function () {
|
|
7
|
-
var dest = hypercore(path.join(__dirname, 'cores/64kb-copy'), source.key, { overwrite: true })
|
|
8
|
-
var then = Date.now()
|
|
9
|
-
|
|
10
|
-
replicate(source, dest).on('end', function () {
|
|
11
|
-
console.log(Math.floor(1000 * dest.byteLength / (Date.now() - then)) + ' bytes/s')
|
|
12
|
-
console.log(Math.floor(1000 * dest.length / (Date.now() - then)) + ' blocks/s')
|
|
13
|
-
})
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
function replicate (a, b) {
|
|
17
|
-
var s = a.replicate(false)
|
|
18
|
-
return s.pipe(b.replicate(true)).pipe(s)
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./helpers/write')('16kb', 16384, 16384)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./helpers/write')('512b', 512, 102400)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./helpers/write')('64kb-static', 65536, 16384, true)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./helpers/write')('64kb', 65536, 16384)
|
package/example.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var hypercore = require('./')
|
|
2
|
-
|
|
3
|
-
var feed = hypercore('./tmp', { valueEncoding: 'json' })
|
|
4
|
-
|
|
5
|
-
feed.append({
|
|
6
|
-
hello: 'world'
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
feed.append({
|
|
10
|
-
hej: 'verden'
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
feed.append({
|
|
14
|
-
hola: 'mundo'
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
feed.flush(function () {
|
|
18
|
-
console.log('Appended 3 more blocks, %d in total (%d bytes)\n', feed.length, feed.byteLength)
|
|
19
|
-
|
|
20
|
-
feed.createReadStream()
|
|
21
|
-
.on('data', console.log)
|
|
22
|
-
.on('end', console.log.bind(console, '\n(end)'))
|
|
23
|
-
})
|
package/lib/cache.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const HypercoreCache = require('hypercore-cache')
|
|
2
|
-
|
|
3
|
-
const DEFAULT_TREE_CACHE_SIZE = 65536 * 40
|
|
4
|
-
|
|
5
|
-
function createCache (opts) {
|
|
6
|
-
if (opts.cache === false) return {}
|
|
7
|
-
|
|
8
|
-
const cacheOpts = opts.cache || {}
|
|
9
|
-
if (cacheOpts.tree === undefined || typeof cacheOpts.tree === 'number') {
|
|
10
|
-
const cacheSize = cacheOpts.tree || opts.storageCacheSize
|
|
11
|
-
cacheOpts.tree = new HypercoreCache({
|
|
12
|
-
maxByteSize: cacheSize !== undefined ? cacheSize : DEFAULT_TREE_CACHE_SIZE,
|
|
13
|
-
estimateSize: () => 40
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
if (cacheOpts.data === undefined) return cacheOpts
|
|
17
|
-
if (typeof cacheOpts.data === 'number') {
|
|
18
|
-
cacheOpts.data = new HypercoreCache({
|
|
19
|
-
maxByteSize: cacheOpts.data,
|
|
20
|
-
estimateSize: buf => buf.length
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
return cacheOpts
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
module.exports = createCache
|
package/lib/crypto.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Before hypercore-crypto existed, all of hypercore's crypto operations lived here.
|
|
2
|
-
// This only exists for backwards compatibility with projects that explicitly require this file.
|
|
3
|
-
// Please use the hypercore-crypto package directly instead.
|
|
4
|
-
// https://github.com/mafintosh/hypercore-crypto
|
|
5
|
-
module.exports = require('hypercore-crypto')
|