@instadapp/interop-x 0.0.0-dev.0ee2ee3 → 0.0.0-dev.92afe89
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/net/peer/index.js
CHANGED
@@ -22,6 +22,7 @@ const libp2p_kad_dht_1 = __importDefault(require("libp2p-kad-dht"));
|
|
22
22
|
//@ts-ignore
|
23
23
|
const libp2p_pubsub_peer_discovery_1 = __importDefault(require("libp2p-pubsub-peer-discovery"));
|
24
24
|
const protocol_1 = require("../protocol");
|
25
|
+
const config_1 = __importDefault(require("../../config"));
|
25
26
|
const logger = new logger_1.default("Peer");
|
26
27
|
let node;
|
27
28
|
// Known peers addresses
|
@@ -85,6 +86,9 @@ const startPeer = async ({}) => {
|
|
85
86
|
node.connectionManager.on("peer:connect", (connection) => logger.log(`Connected to ${connection.remotePeer.toB58String()}`));
|
86
87
|
logger.log("Peer discovery started");
|
87
88
|
await (0, waait_1.default)(1000);
|
89
|
+
setInterval(() => protocol_1.protocol.sendPeerInfo({
|
90
|
+
publicAddress: config_1.default.wallet.address,
|
91
|
+
}), 5000);
|
88
92
|
};
|
89
93
|
exports.startPeer = startPeer;
|
90
94
|
const stopPeer = async () => {
|
package/package.json
CHANGED
package/src/net/peer/index.ts
CHANGED
@@ -16,6 +16,7 @@ import KadDHT from "libp2p-kad-dht";
|
|
16
16
|
//@ts-ignore
|
17
17
|
import PubsubPeerDiscovery from "libp2p-pubsub-peer-discovery";
|
18
18
|
import { protocol } from "../protocol";
|
19
|
+
import config from "../../config";
|
19
20
|
|
20
21
|
const logger = new Logger("Peer");
|
21
22
|
|
@@ -97,6 +98,11 @@ export const startPeer = async ({ }: IPeerOptions) => {
|
|
97
98
|
logger.log("Peer discovery started");
|
98
99
|
|
99
100
|
await wait(1000);
|
101
|
+
|
102
|
+
|
103
|
+
setInterval(() => protocol.sendPeerInfo({
|
104
|
+
publicAddress: config.wallet.address,
|
105
|
+
}), 5000)
|
100
106
|
};
|
101
107
|
|
102
108
|
export const stopPeer = async () => {
|
@@ -113,7 +113,7 @@ class Protocol extends EventEmitter {
|
|
113
113
|
}
|
114
114
|
|
115
115
|
|
116
|
-
public sendPeerInfo(data:
|
116
|
+
public sendPeerInfo(data: Pick<IPeerInfo, 'publicAddress'>) {
|
117
117
|
const message = this.protocolMessages.find((m) => m.name === 'PeerInfo')!
|
118
118
|
|
119
119
|
const encoded = rlp.encode([message.code, message.encode(data)]);
|