Skip to content

Commit

Permalink
chore: Remove DivLogger, usages and teavm debug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zurcusa committed Sep 30, 2024
1 parent 8d52383 commit 461c999
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 63 deletions.
8 changes: 0 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,4 @@ teavm.js {
mainClass = "com.limechain.Main"
targetFileName = "fruzhin.js"
moduleType = JSModuleType.ES2015
}

//TODO: Debug only. Remove when doing release build
teavm {
js {
sourceMap.set(true)
debugInformation.set(true)
}
}
11 changes: 4 additions & 7 deletions src/main/java/com/limechain/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@
import com.limechain.config.CommonConfig;
import com.limechain.rpc.WsRpcClient;
import com.limechain.rpc.WsRpcClientImpl;
import com.limechain.utils.DivLogger;
import lombok.extern.java.Log;
import org.teavm.jso.JSBody;
import org.teavm.jso.core.JSString;

import java.util.logging.Level;

@Log
public class Main {

private static final String WS_RPC = "wsRpc";

private static final DivLogger log = new DivLogger();

public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalStateException(
"Please provide a valid chain spec string or one of the supported chain names.");
}

log.log("Starting LimeChain node...");
log.info("Starting LimeChain node...");

String chainString = args[0];
initContext(chainString);

HostNode client = new LightClient();
client.start();

log.log(Level.INFO, "\uD83D\uDE80Started light client!");
log.info("\uD83D\uDE80Started light client!");
}

private static void initContext(String chainString) {
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/limechain/client/LightClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
import com.limechain.config.AppBean;
import com.limechain.network.Network;
import com.limechain.sync.warpsync.WarpSyncMachine;
import com.limechain.utils.DivLogger;
import lombok.SneakyThrows;

import java.util.logging.Level;
import lombok.extern.java.Log;

/**
* Main light client class that starts and stops execution of
* the client and hold references to dependencies
*/
@Log
public class LightClient implements HostNode {
// TODO: Add service dependencies i.e rpc, sync, network, etc.
// TODO: Do we need those as fields here...?
private final Network network;

private static final DivLogger log = new DivLogger();

/**
* @implNote the RpcApp is assumed to have been started before constructing the client,
* as it relies on the application context
Expand All @@ -35,7 +32,7 @@ public void start() {
this.network.start();
WarpSyncMachine warpSyncMachine = AppBean.getBean(WarpSyncMachine.class);

log.log(Level.INFO, "Syncing to latest finalized block state...");
log.fine("Syncing to latest finalized block state...");

int retryCount = 0;
while (retryCount < 3) {
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/limechain/config/ChainService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import com.limechain.chain.Chain;
import com.limechain.chain.spec.ChainSpec;
import com.limechain.polkaj.Hash256;
import com.limechain.utils.DivLogger;
import com.limechain.utils.json.ObjectMapper;
import lombok.Getter;

import java.util.logging.Level;
import lombok.extern.java.Log;

// TODO: Cleanup

/**
* Configuration class used to store any Host specific information
*/
@Getter
@Log
public class ChainService {

private static final String GENESIS_DIR_FORMAT = "genesis/%s.json";
Expand All @@ -30,10 +29,8 @@ public class ChainService {
*/
private ChainSpec chainSpec;

private static final DivLogger log = new DivLogger();

public void init(String chainString) {
log.log(Level.INFO, "Loading chain context...");
log.fine("Loading chain context...");

Chain cliChain = Chain.fromString(chainString);
try {
Expand All @@ -48,7 +45,7 @@ public void init(String chainString) {
System.out.println("Something went wrong while loading chain data. " + e.getMessage());
}

log.log(Level.INFO, "✅️Loaded chain context for the " + chain.getValue() + " chain.");
log.info("✅️Loaded chain context for the " + chain.getValue() + " chain.");
}

/**
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/limechain/config/SystemInfo.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package com.limechain.config;

import com.limechain.utils.DivLogger;
import lombok.Getter;

import java.util.logging.Level;
import lombok.extern.java.Log;

//TODO: Cleanup

/**
* Configuration class used to hold and information used by the system rpc methods
*/
@Getter
@Log
public class SystemInfo {
// private final String role;
private final ChainService chainService;
// private final String hostIdentity;
private String hostName = "Fruzhin";
private String hostVersion = "0.0.1";

private static final DivLogger log = new DivLogger();

public SystemInfo(ChainService chainService) {
// this.role = network.getNodeRole().name();
this.chainService = chainService;
Expand All @@ -37,12 +34,12 @@ public void logSystemInfo() {
String labelEmoji = new String(Character.toChars(0x1F3F7));
String authEmoji = new String(Character.toChars(0x1F464));

log.log(Level.INFO, lemonEmoji + "LimeChain Fruzhin");
log.log(Level.INFO, pinEmoji + "Version: " + hostVersion);
log.log(Level.INFO, clipboardEmoji + "Chain specification: " + chainService.getChain().getValue());
log.log(Level.INFO, labelEmoji + "Host name: " + hostName);
// log.log(Level.INFO, authEmoji + "Role: " + role);
// log.log(Level.INFO, "Local node identity is: " + hostIdentity);
log.log(Level.INFO, "Operating System: " + System.getProperty("os.name"));
log.fine(lemonEmoji + "LimeChain Fruzhin");
log.fine(pinEmoji + "Version: " + hostVersion);
log.fine(clipboardEmoji + "Chain specification: " + chainService.getChain().getValue());
log.fine(labelEmoji + "Host name: " + hostName);
// log.fine(authEmoji + "Role: " + role);
// log.fine("Local node identity is: " + hostIdentity);
log.fine("Operating System: " + System.getProperty("os.name"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@
import com.limechain.sync.warpsync.action.RpcFallbackAction;
import com.limechain.sync.warpsync.action.WarpSyncAction;
import com.limechain.tuple.Pair;
import com.limechain.utils.DivLogger;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.java.Log;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.logging.Level;

@Getter
@Setter
@Log
public class WarpSyncMachine {

private static final DivLogger log = new DivLogger();

private Queue<WarpSyncFragment> fragmentsQueue;
private WarpSyncAction warpSyncAction;
private boolean isProtocolSync;
Expand Down Expand Up @@ -106,7 +104,7 @@ private void finishWarpSync() {
syncState.persistState(isProtocolSync, chainService.getChain().getId());

System.out.println("Warp sync finished.");
log.log(Level.INFO, "Highest known block at #" + syncState.getLastFinalizedBlockNumber());
log.info("Highest known block at #" + syncState.getLastFinalizedBlockNumber());

onFinishCallbacks.forEach(Runnable::run);
networkService.sendBlockAnnounceHandshake();
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/com/limechain/utils/DivLogger.java

This file was deleted.

0 comments on commit 461c999

Please sign in to comment.