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) }