forked from LimeChain/Fruzhin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '495-setup-kademlia' into 494-sync-state-rpc-calls
# Conflicts: # src/main/java/com/limechain/teavm/HttpRequest.java
- Loading branch information
Showing
33 changed files
with
975 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
src/main/java/com/limechain/chain/lightsyncstate/Authority.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
package com.limechain.chain.lightsyncstate; | ||
|
||
import com.limechain.teavm.annotation.Reflectable; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.io.Serializable; | ||
import java.math.BigInteger; | ||
|
||
@Getter | ||
@Setter | ||
@Reflectable | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Authority implements Serializable { | ||
private final byte[] publicKey; | ||
private final BigInteger weight; | ||
private byte[] publicKey; | ||
private BigInteger weight; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 4 additions & 12 deletions
16
src/main/java/com/limechain/network/StrictProtocolBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
package com.limechain.network; | ||
|
||
public abstract class StrictProtocolBinding<T> { | ||
public abstract class StrictProtocolBinding { | ||
String protocolId; | ||
|
||
protected StrictProtocolBinding(String protocolId/*, T protocol*/) { | ||
this.protocolId = protocolId; | ||
} | ||
|
||
// public T dialPeer(Host us, PeerId peer, AddressBook addrs) { | ||
// Multiaddr[] addr = addrs.get(peer) | ||
// .join().stream() | ||
// .filter(address -> !address.toString().contains("/ws") && !address.toString().contains("/wss")) | ||
// .toList() | ||
// .toArray(new Multiaddr[0]); | ||
// if (addr.length == 0) | ||
// throw new IllegalStateException("No addresses known for peer " + peer); | ||
// | ||
// return dial(us, peer, addr).getController().join(); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 15 additions & 17 deletions
32
src/main/java/com/limechain/network/protocol/warp/WarpSync.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
package com.limechain.network.protocol.warp; | ||
|
||
import com.limechain.network.StrictProtocolBinding; | ||
import com.limechain.network.protocol.warp.dto.WarpSyncResponse; | ||
import lombok.extern.java.Log; | ||
|
||
import java.util.logging.Level; | ||
|
||
@Log | ||
public class WarpSync extends StrictProtocolBinding<WarpSyncController> { | ||
public class WarpSync extends StrictProtocolBinding { | ||
|
||
private final String protocolId; | ||
|
||
public WarpSync(String protocolId, WarpSyncProtocol protocol) { | ||
super(protocolId/*, protocol*/); | ||
public WarpSync(String protocolId) { | ||
super(protocolId); | ||
this.protocolId = protocolId; | ||
} | ||
|
||
// public WarpSyncResponse warpSyncRequest(Host us, PeerId peer, String blockHash) { | ||
// try { | ||
// WarpSyncController controller = dialPeer(us, peer, us.getAddressBook()); | ||
// WarpSyncResponse resp = controller.warpSyncRequest(blockHash).get(10, TimeUnit.SECONDS); | ||
// log.log(Level.INFO, "Received warp sync response with " + resp.getFragments().length + " fragments"); | ||
// return resp; | ||
// } catch (ExecutionException | TimeoutException | IllegalStateException e) { | ||
// log.log(Level.SEVERE, "Error while sending remote call request: ", e); | ||
// throw new ExecutionFailedException(e); | ||
// } catch (InterruptedException e) { | ||
// Thread.currentThread().interrupt(); | ||
// throw new ThreadInterruptedException(e); | ||
// } | ||
// } | ||
public WarpSyncResponse warpSyncRequest(String blockHash) { | ||
WarpSyncProtocol.Sender sender = new WarpSyncProtocol.Sender(); | ||
WarpSyncResponse resp = sender.warpSyncRequest(blockHash, protocolId); | ||
log.log(Level.INFO, "Received warp sync response with " + resp.getFragments().length + " fragments"); | ||
return resp; | ||
} | ||
} |
Oops, something went wrong.