@fireproof/core 0.0.5 → 0.0.7
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/hooks/use-fireproof.ts +0 -2
- package/package.json +6 -5
- package/src/blockstore.js +14 -10
- package/src/clock.js +29 -50
- package/src/db-index.js +109 -69
- package/src/fireproof.js +64 -27
- package/src/listener.js +0 -6
- package/src/prolly.js +68 -52
- package/src/valet.js +6 -62
- package/{src → test}/block.js +6 -6
- package/test/clock.test.js +91 -170
- package/test/db-index.test.js +10 -8
- package/test/fireproof.test.js +84 -16
- package/test/fulltext.test.js +66 -0
- package/test/helpers.js +1 -1
- package/test/prolly.test.js +15 -28
- package/test/proofs.test.js +53 -0
- package/test/reproduce-fixture-bug.test.js +65 -0
- package/hooks/use-fireproof.md +0 -149
- package/scripts/propernames/gen.sh +0 -3
- package/scripts/randomcid.js +0 -12
- package/scripts/words/gen.js +0 -55
package/scripts/words/gen.js
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
import fs from 'node:fs'
|
2
|
-
import { Readable } from 'node:stream'
|
3
|
-
import { CarWriter } from '@ipld/car'
|
4
|
-
import { CID } from 'multiformats/cid'
|
5
|
-
import * as raw from 'multiformats/codecs/raw'
|
6
|
-
import { sha256 } from 'multiformats/hashes/sha2'
|
7
|
-
import { ShardBlock, put } from '../../index.js'
|
8
|
-
import { MemoryBlockstore } from '../../block.js'
|
9
|
-
|
10
|
-
/** @param {string} str */
|
11
|
-
async function stringToCID (str) {
|
12
|
-
const hash = await sha256.digest(new TextEncoder().encode(str))
|
13
|
-
return CID.create(1, raw.code, hash)
|
14
|
-
}
|
15
|
-
|
16
|
-
async function main () {
|
17
|
-
const data = await fs.promises.readFile('/usr/share/dict/words', 'utf8')
|
18
|
-
const words = data.split(/\n/)
|
19
|
-
const cids = await Promise.all(words.map(stringToCID))
|
20
|
-
const blocks = new MemoryBlockstore()
|
21
|
-
const rootblk = await ShardBlock.create()
|
22
|
-
blocks.putSync(rootblk.cid, rootblk.bytes)
|
23
|
-
|
24
|
-
console.time(`put x${words.length}`)
|
25
|
-
/** @type {import('../../shard').ShardLink} */
|
26
|
-
let root = rootblk.cid
|
27
|
-
for (const [i, word] of words.entries()) {
|
28
|
-
const res = await put(blocks, root, word, cids[i])
|
29
|
-
root = res.root
|
30
|
-
for (const b of res.additions) {
|
31
|
-
blocks.putSync(b.cid, b.bytes)
|
32
|
-
}
|
33
|
-
for (const b of res.removals) {
|
34
|
-
blocks.deleteSync(b.cid)
|
35
|
-
}
|
36
|
-
if (i % 1000 === 0) {
|
37
|
-
console.log(`${Math.floor(i / words.length * 100)}%`)
|
38
|
-
}
|
39
|
-
}
|
40
|
-
console.timeEnd(`put x${words.length}`)
|
41
|
-
|
42
|
-
// @ts-expect-error
|
43
|
-
const { writer, out } = CarWriter.create(root)
|
44
|
-
const finishPromise = new Promise(resolve => {
|
45
|
-
Readable.from(out).pipe(fs.createWriteStream('./pail.car')).on('finish', resolve)
|
46
|
-
})
|
47
|
-
|
48
|
-
for (const b of blocks.entries()) {
|
49
|
-
await writer.put(b)
|
50
|
-
}
|
51
|
-
await writer.close()
|
52
|
-
await finishPromise
|
53
|
-
}
|
54
|
-
|
55
|
-
main()
|