pinokiod 3.8.86 → 3.8.87
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/kernel/peer.js +18 -3
- package/package.json +1 -1
package/kernel/peer.js
CHANGED
|
@@ -39,6 +39,15 @@ class PeerDiscovery {
|
|
|
39
39
|
setInterval(() => {
|
|
40
40
|
console.log("send message to peers")
|
|
41
41
|
this.socket.send(this.message, 0, this.message.length, this.port, '255.255.255.255');
|
|
42
|
+
|
|
43
|
+
// if peer exists but info doesn't exist, refresh
|
|
44
|
+
for(let peer of this.peers) {
|
|
45
|
+
if (!this.info[peer]) {
|
|
46
|
+
// retrying
|
|
47
|
+
console.log("retrying for peer", peer)
|
|
48
|
+
this.refresh([peer])
|
|
49
|
+
}
|
|
50
|
+
}
|
|
42
51
|
}, this.interval);
|
|
43
52
|
});
|
|
44
53
|
}
|
|
@@ -71,9 +80,15 @@ class PeerDiscovery {
|
|
|
71
80
|
return res
|
|
72
81
|
}
|
|
73
82
|
// refresh peer info
|
|
74
|
-
async refresh() {
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
async refresh(peers) {
|
|
84
|
+
let refresh_peers
|
|
85
|
+
if (peers) {
|
|
86
|
+
refresh_peers = peers
|
|
87
|
+
} else {
|
|
88
|
+
this.info = {}
|
|
89
|
+
refresh_peers = Array.from(this.peers)
|
|
90
|
+
}
|
|
91
|
+
let peer_info = await Promise.all(refresh_peers.map((host) => {
|
|
77
92
|
return this._refresh(host)
|
|
78
93
|
}))
|
|
79
94
|
console.log({ peer_info })
|