@hive-p2p/server 1.0.67 → 1.0.68

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.
Files changed (2) hide show
  1. package/core/unicast.mjs +6 -2
  2. package/package.json +1 -1
package/core/unicast.mjs CHANGED
@@ -83,6 +83,7 @@ export class UnicastMessager {
83
83
  if (!builtResult.success) return false;
84
84
 
85
85
  // Caution: re-routing usage who can involve insane results
86
+ const destinations = [];
86
87
  const createdMessagePromises = [];
87
88
  const finalSpread = builtResult.success === 'blind' ? 1 : spread; // Spread only if re-routing is false
88
89
  for (let i = 0; i < Math.min(finalSpread, builtResult.routes.length); i++) {
@@ -91,11 +92,14 @@ export class UnicastMessager {
91
92
  if (this.verbose > 1) console.warn(`Cannot send unicast message to ${remoteId} as route exceeds maxHops (${UNICAST.MAX_HOPS}). BFS incurred.`);
92
93
  continue; // too long route
93
94
  }
95
+
96
+ destinations.push(route[1]); // send to next peer
94
97
  createdMessagePromises.push(this.cryptoCodex.createUnicastMessage(type, data, route, this.peerStore.neighborsList));
95
98
  }
96
-
99
+
97
100
  const createdMessages = await Promise.all(createdMessagePromises);
98
- for (const message of createdMessages) this.#sendMessageToPeer(message.route[1], message);
101
+ for (let i = 0; i < createdMessages.length; i++)
102
+ this.#sendMessageToPeer(destinations[i], createdMessages[i]);
99
103
  return true;
100
104
  }
101
105
  /** @param {string} targetId @param {Uint8Array} serialized */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hive-p2p/server",
3
- "version": "1.0.67",
3
+ "version": "1.0.68",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },