@fireproof/core 0.5.4 → 0.5.6
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/dist/src/fireproof.d.ts +1 -0
- package/dist/src/fireproof.js +220 -185
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +220 -185
- package/dist/src/fireproof.mjs.map +1 -1
- package/package.json +1 -1
- package/src/database.js +2 -0
- package/src/db-index.js +1 -1
- package/src/fireproof.js +6 -7
package/package.json
CHANGED
package/src/database.js
CHANGED
@@ -3,12 +3,14 @@ import { visMerkleClock, visMerkleTree, vis, put, get, getAll, eventsSince } fro
|
|
3
3
|
import { doTransaction } from './blockstore.js'
|
4
4
|
import charwise from 'charwise'
|
5
5
|
import { localSet } from './utils.js'
|
6
|
+
import { CID } from 'multiformats'
|
6
7
|
|
7
8
|
// TypeScript Types
|
8
9
|
// eslint-disable-next-line no-unused-vars
|
9
10
|
// import { CID } from 'multiformats/dist/types/src/cid.js'
|
10
11
|
// eslint-disable-next-line no-unused-vars
|
11
12
|
class Proof {}
|
13
|
+
export const parseCID = cid => (typeof cid === 'string' ? CID.parse(cid) : cid)
|
12
14
|
|
13
15
|
/**
|
14
16
|
* @class Fireproof
|
package/src/db-index.js
CHANGED
@@ -17,7 +17,7 @@ import { TransactionBlockstore, doTransaction } from './blockstore.js'
|
|
17
17
|
// @ts-ignore
|
18
18
|
import charwise from 'charwise'
|
19
19
|
|
20
|
-
const ALWAYS_REBUILD = false // todo:
|
20
|
+
const ALWAYS_REBUILD = false // todo: remove
|
21
21
|
|
22
22
|
const compare = (a, b) => {
|
23
23
|
const [aKey, aRef] = a
|
package/src/fireproof.js
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
import randomBytes from 'randombytes'
|
2
2
|
|
3
|
-
import { Database } from './database.js'
|
3
|
+
import { Database, parseCID } from './database.js'
|
4
4
|
import { Listener } from './listener.js'
|
5
5
|
import { DbIndex as Index } from './db-index.js'
|
6
|
-
import { CID } from 'multiformats'
|
7
6
|
import { TransactionBlockstore } from './blockstore.js'
|
8
7
|
import { localGet } from './utils.js'
|
9
8
|
import { blocksToCarBlock, blocksToEncryptedCarBlock } from './valet.js'
|
10
9
|
|
11
10
|
export { Index, Listener, Database }
|
12
11
|
|
13
|
-
const parseCID = cid => (typeof cid === 'string' ? CID.parse(cid) : cid)
|
14
|
-
|
15
12
|
export class Fireproof {
|
16
13
|
/**
|
17
14
|
* @function storage
|
@@ -50,7 +47,7 @@ export class Fireproof {
|
|
50
47
|
clock: {
|
51
48
|
byId: byId ? parseCID(byId) : null,
|
52
49
|
byKey: byKey ? parseCID(byKey) : null,
|
53
|
-
db: db ? db.map(c => parseCID(c)) : null
|
50
|
+
db: (db && db.length > 0) ? db.map(c => parseCID(c)) : null
|
54
51
|
},
|
55
52
|
code,
|
56
53
|
name
|
@@ -95,7 +92,7 @@ export class Fireproof {
|
|
95
92
|
const allCIDs = await database.allCIDs()
|
96
93
|
const blocks = database.blocks
|
97
94
|
|
98
|
-
const rootCid =
|
95
|
+
const rootCid = parseCID(allCIDs[allCIDs.length - 1])
|
99
96
|
if (typeof key === 'undefined') {
|
100
97
|
key = blocks.valet?.getKeyMaterial()
|
101
98
|
}
|
@@ -113,7 +110,9 @@ export class Fireproof {
|
|
113
110
|
allCIDs.map(async c => {
|
114
111
|
const b = await blocks.get(c)
|
115
112
|
// console.log('block', b)
|
116
|
-
if (typeof b.cid === 'string') {
|
113
|
+
if (typeof b.cid === 'string') {
|
114
|
+
b.cid = parseCID(b.cid)
|
115
|
+
}
|
117
116
|
// if (b.bytes.constructor.name === 'Buffer') console.log('conver vbuff')
|
118
117
|
return b
|
119
118
|
})
|