pinokiod 8.0.36 → 8.0.38

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/kernel/index.js CHANGED
@@ -37,6 +37,7 @@ const PinokioDomainRouter = require("./router/pinokio_domain_router")
37
37
  const Procs = require('./procs')
38
38
  const Peer = require('./peer')
39
39
  const Git = require('./git')
40
+ const Vault = require('./vault')
40
41
  const Connect = require('./connect')
41
42
  const Favicon = require('./favicon')
42
43
  const AppLauncher = require('./app_launcher')
@@ -1216,6 +1217,17 @@ class Kernel {
1216
1217
  await this.git.loadCheckpoints()
1217
1218
  console.timeEnd("git.loadCheckpoints")
1218
1219
 
1220
+ // Shared model store: registry verification only at startup — never a
1221
+ // discovery walk (spec/requirements/shared-model-store.md, trigger 5).
1222
+ this.vault = new Vault(this)
1223
+ if (this.homedir) {
1224
+ this.vault.init().then((result) => {
1225
+ if (result && result.enabled) return this.vault.verify()
1226
+ }).catch((err) => {
1227
+ console.warn("Vault init error:", err && err.message ? err.message : err)
1228
+ })
1229
+ }
1230
+
1219
1231
  // let contents = await fs.promises.readdir(this.homedir)
1220
1232
  //await this.bin.init()
1221
1233
  let ts = Date.now()
@@ -0,0 +1,19 @@
1
+ const { parentPort } = require('worker_threads')
2
+ const crypto = require('crypto')
3
+ const fs = require('fs')
4
+
5
+ parentPort.on('message', ({ id, filePath }) => {
6
+ const hash = crypto.createHash('sha256')
7
+ let size = 0
8
+ const stream = fs.createReadStream(filePath)
9
+ stream.on('data', (chunk) => {
10
+ size += chunk.length
11
+ hash.update(chunk)
12
+ })
13
+ stream.on('error', (error) => {
14
+ parentPort.postMessage({ id, error: error.message })
15
+ })
16
+ stream.on('end', () => {
17
+ parentPort.postMessage({ id, hash: hash.digest('hex'), size })
18
+ })
19
+ })