@rljson/network 0.0.1 → 0.0.3
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/dist/network-manager.d.ts +4 -4
- package/dist/network.js +6 -1
- package/package.json +4 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { NodeId, NodeInfo } from './types/node-info.ts';
|
|
2
|
-
import { NetworkConfig } from './types/network-config.ts';
|
|
3
|
-
import { NetworkTopology } from './types/network-topology.ts';
|
|
4
|
-
import { TopologyChangedEvent, RoleChangedEvent, HubChangedEvent } from './types/network-events.ts';
|
|
5
1
|
import { NodeIdentity } from './identity/node-identity.ts';
|
|
6
2
|
import { BroadcastLayerDeps } from './layers/broadcast-layer.ts';
|
|
7
3
|
import { CloudLayerDeps } from './layers/cloud-layer.ts';
|
|
8
4
|
import { ProbeScheduler, ProbeFn } from './probing/probe-scheduler.ts';
|
|
5
|
+
import { NetworkConfig } from './types/network-config.ts';
|
|
6
|
+
import { HubChangedEvent, RoleChangedEvent, TopologyChangedEvent } from './types/network-events.ts';
|
|
7
|
+
import { NetworkTopology } from './types/network-topology.ts';
|
|
8
|
+
import { NodeId, NodeInfo } from './types/node-info.ts';
|
|
9
9
|
/** Events emitted by NetworkManager */
|
|
10
10
|
export interface NetworkManagerEvents {
|
|
11
11
|
'topology-changed': (event: TopologyChangedEvent) => void;
|
package/dist/network.js
CHANGED
|
@@ -1404,6 +1404,10 @@ class NetworkManager {
|
|
|
1404
1404
|
this._peerTable.on("peer-joined", (peer) => {
|
|
1405
1405
|
this._emit("peer-joined", peer);
|
|
1406
1406
|
this._probeScheduler.setPeers(this._peerTable.getPeers());
|
|
1407
|
+
const broadcastPeers = this._broadcastLayer.getPeers();
|
|
1408
|
+
if (broadcastPeers.some((bp) => bp.nodeId === peer.nodeId)) {
|
|
1409
|
+
void this._probeScheduler.runOnce();
|
|
1410
|
+
}
|
|
1407
1411
|
this._recomputeTopology();
|
|
1408
1412
|
});
|
|
1409
1413
|
this._peerTable.on("peer-left", (nodeId) => {
|
|
@@ -1574,10 +1578,11 @@ class NetworkManager {
|
|
|
1574
1578
|
this._identity.toNodeInfo(),
|
|
1575
1579
|
...this._peerTable.getPeers()
|
|
1576
1580
|
];
|
|
1581
|
+
const effectiveIncumbent = this._currentHubId === this._identity.nodeId ? null : this._currentHubId;
|
|
1577
1582
|
const result = electHub(
|
|
1578
1583
|
candidates,
|
|
1579
1584
|
probes,
|
|
1580
|
-
|
|
1585
|
+
effectiveIncumbent,
|
|
1581
1586
|
this._identity.nodeId
|
|
1582
1587
|
);
|
|
1583
1588
|
/* v8 ignore else -- @preserve */
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/network",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Networking middle layer providing basic advertising and discovery as well as cloud fall backs and basic config.",
|
|
5
5
|
"homepage": "https://github.com/rljson/network",
|
|
6
6
|
"bugs": "https://github.com/rljson/network/issues",
|
|
7
7
|
"private": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
8
11
|
"license": "MIT",
|
|
9
12
|
"engines": {
|
|
10
13
|
"node": ">=22.14.0"
|