node.addEventListener('peer:discovery', async (event) => {
const peerInfo = event.detail;
console.log("New peer discovered", peerInfo.id.toString());
const peerInfo = event.detail;
console.log("New peer discovered", peerInfo.id.toString());
const rpcUrl = 'http://127.0.0.1:9944';
const body = JSON.stringify({
jsonrpc: '2.0',
method: 'system_addReservedPeer',
params: [
`/ip4/192.168.1.203/tcp/4003/ws/p2p/${peerId}`
],
id: 2
});
const response = await fetch(rpcUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body
});
node.addEventListener('peer:connect', async (event) => {
console.log('peer connect', event.detail)
console.log('peer connect', event.detail)
})