diff --git a/src/main/java/com/limechain/network/kad/KademliaService.java b/src/main/java/com/limechain/network/kad/KademliaService.java index baf2de5e6..7375dcad6 100644 --- a/src/main/java/com/limechain/network/kad/KademliaService.java +++ b/src/main/java/com/limechain/network/kad/KademliaService.java @@ -1,10 +1,7 @@ package com.limechain.network.kad; -import com.limechain.network.kad.dto.Host; -import com.limechain.network.kad.dto.PeerId; import com.limechain.network.protocol.NetworkService; import lombok.Getter; -import lombok.Setter; import lombok.extern.java.Log; import org.teavm.jso.JSBody; @@ -18,8 +15,6 @@ public class KademliaService extends NetworkService { public static final int REPLICATION = 20; - @Setter - private Host host; private int successfulBootNodes; /** @@ -39,12 +34,6 @@ public int connectBootNodes(String[] bootNodes) { } peer = getPeerId(); } - String peerIdStr = peer.toString(); - byte[] privateKey = getPeerPrivateKey(); - byte[] publicKey = getPeerPublicKey(); - - PeerId peerId = new PeerId(privateKey, publicKey, peerIdStr); - this.host = new Host(peerId); successfulBootNodes = getPeerStoreSize(); @@ -64,12 +53,6 @@ public void updateSuccessfulBootNodes() { @JSBody(script = "return window.fruzhin.libp?.peerId") public static native Object getPeerId(); - @JSBody(script = "return window.fruzhin.libp.peerId.privateKey") - public static native byte[] getPeerPrivateKey(); - - @JSBody(script = "return window.fruzhin.libp.peerId.publicKey") - public static native byte[] getPeerPublicKey(); - @JSBody(script = "return window.fruzhin.libp.getConnections().length") public static native int getPeerStoreSize(); @@ -77,12 +60,12 @@ public void updateSuccessfulBootNodes() { * Populates Kademlia dht with peers closest in distance to a random id then makes connections with our node */ @JSBody(script = "window.fruzhin.libp.peerStore.forEach( async (p) => {" + - " for await (const foundPeer of dht.peerRouting.getClosestPeers(p.id.toBytes())){" + - " if(foundPeer.peer?.multiaddrs?.length > 0){" + - " try{window.fruzhin.libp.dial(foundPeer.peer)}finally{}" + - " }" + - " }" + - "});") + " for await (const foundPeer of dht.peerRouting.getClosestPeers(p.id.toBytes())){" + + " if(foundPeer.peer?.multiaddrs?.length > 0){" + + " try{window.fruzhin.libp.dial(foundPeer.peer)}finally{}" + + " }" + + " }" + + "});") public static native void findNewPeers(); } \ No newline at end of file diff --git a/src/main/java/com/limechain/network/kad/dto/Host.java b/src/main/java/com/limechain/network/kad/dto/Host.java deleted file mode 100644 index 27fa98632..000000000 --- a/src/main/java/com/limechain/network/kad/dto/Host.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.limechain.network.kad.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -@AllArgsConstructor -@Getter -@Setter -public class Host { - private PeerId peerId; -} diff --git a/src/main/java/com/limechain/network/kad/dto/PeerId.java b/src/main/java/com/limechain/network/kad/dto/PeerId.java deleted file mode 100644 index c4e13249d..000000000 --- a/src/main/java/com/limechain/network/kad/dto/PeerId.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.limechain.network.kad.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.teavm.jso.JSObject; - -@AllArgsConstructor -@Getter -public class PeerId implements JSObject { - private byte[] privateKey; - private byte[] publicKey; - private String peerIdStr; -} diff --git a/src/main/webapp/js/fruzhin-lib.js b/src/main/webapp/js/fruzhin-lib.js index f84915d2d..2e5344637 100644 --- a/src/main/webapp/js/fruzhin-lib.js +++ b/src/main/webapp/js/fruzhin-lib.js @@ -1,16 +1,16 @@ -import 'https://unpkg.com/@chainsafe/libp2p-yamux@6.0.2/dist/index.min.js'; -import 'https://unpkg.com/@chainsafe/libp2p-noise@15.1.2/dist/index.min.js'; -import 'https://unpkg.com/@libp2p/websockets@8.2.0/dist/index.min.js'; -import 'https://unpkg.com/@libp2p/kad-dht@12.1.5/dist/index.min.js'; -import 'https://unpkg.com/@libp2p/identify@2.1.5/dist/index.min.js'; -import 'https://unpkg.com/@libp2p/bootstrap@10.1.5/dist/index.min.js'; -import 'https://unpkg.com/@libp2p/ping@1.1.6/dist/index.min.js'; -import 'https://unpkg.com/@chainsafe/libp2p-gossipsub@13.2.0/dist/index.min.js'; -import 'https://unpkg.com/libp2p@1.9.4/dist/index.min.js'; -import 'https://unpkg.com/it-pipe@3.0.1/dist/index.min.js'; +import 'https://unpkg.com/@chainsafe/libp2p-gossipsub@14.0.0/dist/index.min.js'; +import 'https://unpkg.com/@chainsafe/libp2p-noise@16.0.0/dist/index.min.js'; +import 'https://unpkg.com/@chainsafe/libp2p-yamux@7.0.0/dist/index.min.js'; +import 'https://unpkg.com/libp2p@2.0.1/dist/index.min.js'; +import 'https://unpkg.com/@libp2p/bootstrap@11.0.0/dist/index.min.js'; +import 'https://unpkg.com/@libp2p/identify@3.0.0/dist/index.min.js'; +import 'https://unpkg.com/@libp2p/kad-dht@13.0.0/dist/index.min.js'; +import 'https://unpkg.com/@libp2p/ping@2.0.0/dist/index.min.js'; +import 'https://unpkg.com/@libp2p/websockets@9.0.0/dist/index.min.js'; import 'https://unpkg.com/it-pb-stream@4.0.2/dist/index.min.js'; -import 'https://unpkg.com/@muradsenteca/ed25519@1.0.0/dist/index.min.js' +import 'https://unpkg.com/it-pipe@3.0.1/dist/index.min.js'; import 'https://unpkg.com/@muradsenteca/blake2b@1.0.1/dist/index.min.js' +import 'https://unpkg.com/@muradsenteca/ed25519@1.0.0/dist/index.min.js' import * as HTTP from './http.js'; import * as Fruzhin from './fruzhin.js' @@ -25,7 +25,7 @@ var startLibp2p = async (bootnodes) => { Libp2PWebsockets.webSockets() ], streamMuxers: [ChainsafeLibp2PYamux.yamux()], - connectionEncryption: [ChainsafeLibp2PNoise.noise()], + connectionEncrypters: [ChainsafeLibp2PNoise.noise()], peerDiscovery: [ Libp2PBootstrap.bootstrap({ list: bootnodes