@hive-p2p/server 1.0.66 → 1.0.67

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 +5 -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 createdMessagePromises = [];
86
87
  const finalSpread = builtResult.success === 'blind' ? 1 : spread; // Spread only if re-routing is false
87
88
  for (let i = 0; i < Math.min(finalSpread, builtResult.routes.length); i++) {
88
89
  const route = builtResult.routes[i].path;
@@ -90,9 +91,11 @@ export class UnicastMessager {
90
91
  if (this.verbose > 1) console.warn(`Cannot send unicast message to ${remoteId} as route exceeds maxHops (${UNICAST.MAX_HOPS}). BFS incurred.`);
91
92
  continue; // too long route
92
93
  }
93
- const message = await this.cryptoCodex.createUnicastMessage(type, data, route, this.peerStore.neighborsList);
94
- this.#sendMessageToPeer(route[1], message); // send to next peer
94
+ createdMessagePromises.push(this.cryptoCodex.createUnicastMessage(type, data, route, this.peerStore.neighborsList));
95
95
  }
96
+
97
+ const createdMessages = await Promise.all(createdMessagePromises);
98
+ for (const message of createdMessages) this.#sendMessageToPeer(message.route[1], message);
96
99
  return true;
97
100
  }
98
101
  /** @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.66",
3
+ "version": "1.0.67",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },