From eca442751b12a4b9f8ef9155eecc4e87d52ecf8b Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:02:03 +0200 Subject: [PATCH] unslab mutablePut, immutablePut and announce (#190) * unslab mutablePut, immutablePut and announce * format cleaner * move record back --------- Co-authored-by: Mathias Buus --- lib/persistent.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/persistent.js b/lib/persistent.js index d2e001f9..528fb703 100644 --- a/lib/persistent.js +++ b/lib/persistent.js @@ -3,6 +3,8 @@ const sodium = require('sodium-universal') const RecordCache = require('record-cache') const Cache = require('xache') const b4a = require('b4a') +const unslab = require('unslab') + const m = require('./messages') const { NS, ERROR } = require('./constants') @@ -122,7 +124,7 @@ module.exports = class Persistent { const k = b4a.toString(req.target, 'hex') const announceSelf = b4a.equals(TMP, req.target) - const record = c.encode(m.peer, peer) + const record = unslab(c.encode(m.peer, peer)) if (announceSelf) { this.dht._router.set(k, { @@ -194,7 +196,8 @@ module.exports = class Persistent { } } - this.mutables.set(k, c.encode(m.mutableGetResponse, { seq, value, signature })) + const entry = c.encode(m.mutableGetResponse, { seq, value, signature }) + this.mutables.set(k, unslab(entry)) req.reply(null) } @@ -215,7 +218,7 @@ module.exports = class Persistent { if (!b4a.equals(hash, req.target)) return const k = b4a.toString(hash, 'hex') - this.immutables.set(k, req.value) + this.immutables.set(k, unslab(req.value)) req.reply(null) }