@reticulum/dacar 1.2.1 → 1.2.2
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/package.json +1 -1
- package/src/transport/rfedSync.js +45 -1
package/package.json
CHANGED
|
@@ -46,10 +46,12 @@
|
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
+
import { Destination } from "@reticulum/core/src/core/destination.js";
|
|
49
50
|
import {
|
|
50
51
|
deriveChannel,
|
|
51
52
|
unwrapRawChannelMessage,
|
|
52
53
|
} from "@reticulum/core/src/rfed/index.js";
|
|
54
|
+
import { MicroMsgPack } from "@reticulum/core/src/utils/msgpack.js";
|
|
53
55
|
import { RFED_TOPIC } from "../naming.js";
|
|
54
56
|
|
|
55
57
|
/**
|
|
@@ -182,8 +184,29 @@ export class RfedDeltaSync {
|
|
|
182
184
|
throw new Error("RfedDeltaSync.listen requires a receiver");
|
|
183
185
|
}
|
|
184
186
|
const receiver = this._receiver;
|
|
185
|
-
return this._client.listen((decoded) => {
|
|
187
|
+
return this._client.listen(async (decoded) => {
|
|
186
188
|
if (decoded?.kind !== "raw") return; // not a raw channel payload
|
|
189
|
+
|
|
190
|
+
// Remember the sender identity so future RNS recalls succeed without
|
|
191
|
+
// needing an announce. Best-effort: decode must still succeed without it.
|
|
192
|
+
try {
|
|
193
|
+
// Extract issuer_hash (field [0]) from the delta to map identity.
|
|
194
|
+
const decodedDelta = MicroMsgPack.decode(decoded.payload);
|
|
195
|
+
if (Array.isArray(decodedDelta) && decodedDelta.length > 0) {
|
|
196
|
+
const issuerHash = decodedDelta[0];
|
|
197
|
+
if (issuerHash instanceof Uint8Array && issuerHash.length === 16) {
|
|
198
|
+
await Destination.remember(
|
|
199
|
+
decoded.senderIdentity.identityHash,
|
|
200
|
+
decoded.senderIdentity.identityHash,
|
|
201
|
+
decoded.senderPub,
|
|
202
|
+
null,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
// Remembering is best-effort; failure doesn't affect correctness.
|
|
208
|
+
}
|
|
209
|
+
|
|
187
210
|
// RFedClient.invoke does not await the callback; run applyPayload without
|
|
188
211
|
// leaving an unhandled rejection (it swallows malformed payloads itself).
|
|
189
212
|
Promise.resolve(receiver.applyPayload(decoded.payload)).catch(() => {});
|
|
@@ -224,6 +247,27 @@ export class RfedDeltaSync {
|
|
|
224
247
|
innerBlob: item.blob,
|
|
225
248
|
channelIdentity,
|
|
226
249
|
});
|
|
250
|
+
|
|
251
|
+
// Remember the sender identity so future RNS recalls succeed without
|
|
252
|
+
// needing an announce. Best-effort: decode must still succeed without it.
|
|
253
|
+
try {
|
|
254
|
+
// Extract issuer_hash (field [0]) from the delta to map identity.
|
|
255
|
+
const decodedDelta = MicroMsgPack.decode(decoded.payload);
|
|
256
|
+
if (Array.isArray(decodedDelta) && decodedDelta.length > 0) {
|
|
257
|
+
const issuerHash = decodedDelta[0];
|
|
258
|
+
if (issuerHash instanceof Uint8Array && issuerHash.length === 16) {
|
|
259
|
+
await Destination.remember(
|
|
260
|
+
decoded.senderIdentity.identityHash,
|
|
261
|
+
decoded.senderIdentity.identityHash,
|
|
262
|
+
decoded.senderPub,
|
|
263
|
+
null,
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
} catch {
|
|
268
|
+
// Remembering is best-effort; failure doesn't affect correctness.
|
|
269
|
+
}
|
|
270
|
+
|
|
227
271
|
if (await receiver.applyPayload(decoded.payload)) {
|
|
228
272
|
applied++;
|
|
229
273
|
}
|