Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into 519-support-more-rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Zurcusa committed Sep 19, 2024
2 parents 87d5d16 + 36bb826 commit b265f5d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 72 deletions.
29 changes: 6 additions & 23 deletions src/main/java/com/limechain/network/kad/KademliaService.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -18,8 +15,6 @@
public class KademliaService extends NetworkService {
public static final int REPLICATION = 20;

@Setter
private Host host;
private int successfulBootNodes;

/**
Expand All @@ -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();

Expand All @@ -64,25 +53,19 @@ 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();

/**
* 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();

}
12 changes: 0 additions & 12 deletions src/main/java/com/limechain/network/kad/dto/Host.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/com/limechain/network/kad/dto/PeerId.java

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/webapp/genesis/ksmcc3.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/main/webapp/genesis/polkadot.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/main/webapp/genesis/westend2.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/main/webapp/js/fruzhin-lib.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'https://unpkg.com/@chainsafe/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@chainsafe/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@chainsafe/[email protected]/dist/index.min.js';
import 'https://unpkg.com/[email protected]/dist/index.min.js';
import 'https://unpkg.com/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@chainsafe/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@chainsafe/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@chainsafe/[email protected]/dist/index.min.js';
import 'https://unpkg.com/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/@libp2p/[email protected]/dist/index.min.js';
import 'https://unpkg.com/[email protected]/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/[email protected]/dist/index.min.js'
import 'https://unpkg.com/@muradsenteca/[email protected]/dist/index.min.js'

import * as HTTP from './http.js';
import * as Fruzhin from './fruzhin.js'
Expand All @@ -25,7 +25,7 @@ var startLibp2p = async (bootnodes) => {
Libp2PWebsockets.webSockets()
],
streamMuxers: [ChainsafeLibp2PYamux.yamux()],
connectionEncryption: [ChainsafeLibp2PNoise.noise()],
connectionEncrypters: [ChainsafeLibp2PNoise.noise()],
peerDiscovery: [
Libp2PBootstrap.bootstrap({
list: bootnodes
Expand Down

0 comments on commit b265f5d

Please sign in to comment.