@leofcoin/peernet 0.9.6 → 0.9.7
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/browser/peernet.js +655 -659
- package/dist/commonjs/peernet.js +655 -659
- package/dist/module/peernet.js +5 -9
- package/package.json +1 -1
- package/src/dht/dht.js +5 -9
package/dist/module/peernet.js
CHANGED
|
@@ -244,7 +244,7 @@ class LeofcoinStorage$1 {
|
|
|
244
244
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
var version = "0.9.
|
|
247
|
+
var version = "0.9.6";
|
|
248
248
|
|
|
249
249
|
var api$1 = {
|
|
250
250
|
version: ({send}) => send({client: '@peernet/api/http', version}),
|
|
@@ -1801,17 +1801,13 @@ class DhtEarth {
|
|
|
1801
1801
|
const peerLoc = await this.getCoordinates(address);
|
|
1802
1802
|
|
|
1803
1803
|
for (const provider of providers) {
|
|
1804
|
-
all.push(
|
|
1804
|
+
if (provider.address === '127.0.0.1') all.push({provider, distance: 0});
|
|
1805
|
+
else all.push(this.getDistance(peerLoc, provider));
|
|
1805
1806
|
}
|
|
1806
1807
|
|
|
1807
1808
|
all = await Promise.all(all);
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
if (!c.distance || c.distance === NaN) c.distance = 0;
|
|
1811
|
-
if (c.distance < p || p === 0) return c.provider;
|
|
1812
|
-
}, 0);
|
|
1813
|
-
|
|
1814
|
-
return closestPeer;
|
|
1809
|
+
all = all.sort((previous, current) => previous.distance - current.distance);
|
|
1810
|
+
return all[0].provider;
|
|
1815
1811
|
}
|
|
1816
1812
|
|
|
1817
1813
|
/**
|
package/package.json
CHANGED
package/src/dht/dht.js
CHANGED
|
@@ -88,17 +88,13 @@ export default class DhtEarth {
|
|
|
88
88
|
const peerLoc = await this.getCoordinates(address)
|
|
89
89
|
|
|
90
90
|
for (const provider of providers) {
|
|
91
|
-
all.push(
|
|
91
|
+
if (provider.address === '127.0.0.1') all.push({provider, distance: 0})
|
|
92
|
+
else all.push(this.getDistance(peerLoc, provider))
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
all = await Promise.all(all)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (!c.distance || c.distance === NaN) c.distance = 0
|
|
98
|
-
if (c.distance < p || p === 0) return c.provider;
|
|
99
|
-
}, 0)
|
|
100
|
-
|
|
101
|
-
return closestPeer;
|
|
95
|
+
all = await Promise.all(all);
|
|
96
|
+
all = all.sort((previous, current) => previous.distance - current.distance)
|
|
97
|
+
return all[0].provider;
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
/**
|