Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eg gridnoderefactor #137

Merged
merged 5 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Building
--------
To build a working package, you first need to create an app-image that can hold the native binaries of the Unigrid daemon;
```
mvn clean package # will build a jlink distribution and an app-image
mvn clean install # will build a jlink distribution and an app-image
```

Finally, we create the actual installer image with everything;
Expand All @@ -43,7 +43,7 @@ To perform a new release we now must also update the config files and upload the
Once the version number has been updated you can run the build process.

```
mvn clean package
mvn clean install
```

In the next step we must update the `fxJarUrl` in UpdateWalletConfig.java. To generate this new url we will have to create a release in this repo [unigrid-update](https://github.com/unigrid-project/unigrid-update/releases). Create a new tag using this format `v1.0.1` then name the release title the version number `1.0.1`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ of the License (see COPYING and COPYING.addendum).
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import java.io.File;
import java.util.ArrayList;
import org.eclipse.aether.repository.LocalRepository;
Expand Down Expand Up @@ -247,6 +245,10 @@ public List<FileMetadata> getExternalDependencies(OS os, File baseDir, boolean t
}

list.add(getFileByUrl(getDaemonUrl(os)));
// TODO add a way for this to be handled automatically
/*if (testing) {
list.add(getFileByUrl("https://github.com/unigrid-project/daemon/releases/download/v2.9.3/unigrid-2.9.3-x86_64-linux-testnet.tar.gz"));
}*/
} catch (IOException ex) {
java.util.logging.Logger.getLogger(UpdateWalletConfig.class.getName())
.log(Level.SEVERE, null, ex);
Expand Down
14 changes: 9 additions & 5 deletions fx/src/main/java/org/unigrid/janus/Janus.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ of the License (see COPYING and COPYING.addendum).
import org.unigrid.janus.model.producer.HostServicesProducer;
import org.unigrid.janus.model.rpc.entity.GetBootstrappingInfo;
import org.unigrid.janus.model.rpc.entity.GetWalletInfo;
import org.unigrid.janus.model.rpc.entity.Info;
import org.unigrid.janus.view.AlertDialog;
//import org.unigrid.janus.model.service.TrayService;

Expand All @@ -76,7 +75,6 @@ public class Janus extends BaseApplication implements PropertyChangeListener {
private String startupStatus;
private String walletVersion;
private String progress = "0";
private Info info = new Info();
private Boolean checkForStatus = true;

@PostConstruct
Expand Down Expand Up @@ -216,10 +214,16 @@ protected Void call() throws Exception {
final GetBootstrappingInfo boostrapInfo = rpc.call(
new GetBootstrappingInfo.Request(), GetBootstrappingInfo.class
);
try {
walletStatus = boostrapInfo.getResult().getWalletstatus();
progress = boostrapInfo.getResult().getProgress();
status = boostrapInfo.getResult().getStatus();
} catch (Exception e) {
// TODO: handle exception
debug.print("boostrapInfo null: " + e.getMessage().toString(),
Janus.class.getSimpleName());
}

walletStatus = boostrapInfo.getResult().getWalletstatus();
progress = boostrapInfo.getResult().getProgress();
status = boostrapInfo.getResult().getStatus();
Thread.sleep(2000);
} catch (Exception e) {
debug.print("RPC call error: " + e.getMessage().toString(),
Expand Down
5 changes: 5 additions & 0 deletions fx/src/main/java/org/unigrid/janus/JanusLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public void run(LaunchContext lc) {
BootstrapModel.setBootstrapVer(bootstrapVer);
}

if (inputArgs.containsKey("testnet")) {
System.out.println("**** TESTNET ****");
BootstrapModel.setTestnet(true);
}

if (inputArgs.containsKey("downloadUrl")) {
BootstrapModel.setDownloadUrl(inputArgs.get("downloadUrl"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ of the License (see COPYING and COPYING.addendum).
import org.unigrid.janus.model.service.DebugService;
import org.unigrid.janus.model.service.RPCService;
import org.unigrid.janus.model.Wallet;
import org.unigrid.janus.model.rpc.entity.Info;
import org.unigrid.janus.model.rpc.entity.UnlockWallet;
import org.unigrid.janus.model.signal.NodeRequest;
import org.unigrid.janus.model.signal.OverlayRequest;
Expand Down Expand Up @@ -133,8 +132,6 @@ private void submit() {
Jsonb jsonb = JsonbBuilder.create();

if (call.getError() != null) {
final Info info = rpc.call(new Info.Request(), Info.class);
wallet.setInfo(info);
String result = call.getError().getMessage();

if (result != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ of the License (see COPYING and COPYING.addendum).
import org.controlsfx.control.Notifications;
import org.kordamp.ikonli.javafx.FontIcon;
import org.unigrid.janus.model.Address;
import org.unigrid.janus.model.BootstrapModel;
import org.unigrid.janus.model.Address.Amount;
import org.unigrid.janus.model.service.DebugService;
import org.unigrid.janus.model.service.RPCService;
Expand Down Expand Up @@ -120,7 +121,11 @@ public void initialize(URL url, ResourceBundle rb) {
}

public void compareBlockHeights() {
//if (wallet.getCheckExplorer()) {
if (BootstrapModel.isTestnet()) {
// FIRE STOP SYNCING EVENT
wallet.setSyncStatus(Wallet.SyncStatus.from("synced"));
return;
}
int explorerHeight;
try {
explorerHeight = wallet.getExplorerHeight();
Expand Down
3 changes: 1 addition & 2 deletions fx/src/main/java/org/unigrid/janus/model/BootstrapModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class BootstrapModel {

@Getter @Setter private static String downloadUrl =
"https://github.com/unigrid-project/janus-java/releases/download/";

@Getter @Setter private static boolean testing;
@Getter @Setter private static boolean testnet;
@Getter @Setter private static boolean bootstrapUpdate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ of the License (see COPYING and COPYING.addendum).
public class DataDirectory {
private static final String APPLICATION_NAME = "UNIGRID";
public static final String CONFIG_FILE = "unigrid.conf";
public static final String GRIDNODE_FILE = "masternode.conf";
public static final String GRIDNODE_FILE = "gridnode.conf";
public static final String DEBUG_LOG = "debug.log";
private static final String OSX_SUPPORT_DIR = "Library/Application Support";

Expand Down
15 changes: 0 additions & 15 deletions fx/src/main/java/org/unigrid/janus/model/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ of the License (see COPYING and COPYING.addendum).
import lombok.Setter;
import org.unigrid.janus.model.cdi.Eager;
import org.unigrid.janus.model.rpc.entity.GetWalletInfo;
import org.unigrid.janus.model.rpc.entity.Info;
import org.unigrid.janus.model.rpc.entity.StakingStatus;
import org.unigrid.janus.model.service.DebugService;

Expand Down Expand Up @@ -298,20 +297,6 @@ public void setStatus(String newValue) {
this.pcs.firePropertyChange(this.STATUS_PROPERTY, oldValue, newValue);
}

public void setInfo(Info newInfo) {
this.setBalance(newInfo.getResult().getBalance());
this.setTotalBalance(newInfo.getResult().getTotalbalance());
this.setMoneysupply(newInfo.getResult().getMoneysupply());
this.setBlocks(newInfo.getResult().getBlocks());
this.setConnections(newInfo.getResult().getConnections());
//disable processing indicator
this.setProcessingStatus();
this.setStatus(newInfo.getResult().getBootstrapping().getWalletstatus());
//String unlock = String.format("Unlock Until: %s", newInfo.getResult().getUnlockUntil());
//debug.log(unlock);

}

public void setWalletState(LockState state) {
LockState oldValue = this.lockState;
lockState = state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ of the License (see COPYING and COPYING.addendum).
@Data
@EqualsAndHashCode(callSuper = false)
public class GridnodeEntity extends BaseResult<String> {
private static final String METHOD = "masternode";
private static final String METHOD = "gridnode";

// masternode <start|start-alias|start-many|stop|stop-alias|stop-many|list|list-conf|
// gridnode <start|start-alias|start-many|stop|stop-alias|stop-many|list|list-conf|
// count|debug|current|winners|genkey|enforce|outputs> [passphrase]
public static class Request extends BaseRequest {
public Request(Object[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ of the License (see COPYING and COPYING.addendum).
@Data
@EqualsAndHashCode(callSuper = false)
public class GridnodeList extends BaseResult<List<GridnodeList.Result>> {
private static final String METHOD = "masternode";
private static final String METHOD = "gridnode";

// masternode <start|start-alias|start-many|stop|stop-alias|stop-many|list|list-conf|
// gridnode <start|start-alias|start-many|stop|stop-alias|stop-many|list|list-conf|
// count|debug|current|winners|genkey|enforce|outputs> [passphrase]
public static class Request extends BaseRequest {
public Request(Object[] args) {
Expand Down
8 changes: 7 additions & 1 deletion fx/src/main/java/org/unigrid/janus/model/service/Daemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ of the License (see COPYING and COPYING.addendum).
import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.unigrid.janus.model.BootstrapModel;
import org.unigrid.janus.model.Preferences;
import org.unigrid.janus.model.cdi.Eager;
import org.unigrid.janus.model.rpc.entity.GetBlockCount;
Expand Down Expand Up @@ -97,7 +98,9 @@ private void init() {

private void runDaemon() throws IOException {
debug.print("starting daemon", Daemon.class.getSimpleName());
process = Optional.of(Runtime.getRuntime().exec(new String[] {location}));
String testnet = BootstrapModel.isTestnet() ? "-testnet" : "-daemon";
ProcessBuilder pb = new ProcessBuilder(location, testnet);
process = Optional.of(pb.start());
}

private boolean isDaemonRunning() {
Expand Down Expand Up @@ -205,6 +208,9 @@ public String getRPCAdress() {
} catch (MalformedURLException e) {
/* Empty on purose */
}
if (BootstrapModel.isTestnet()) {
return "http://127.0.0.1:51995";
}

return "http://127.0.0.1:51993";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void stopPolling() {
}

public <R, T> T call(R request, Class<T> clazz) {
// debug.print("RPC call ".concat(request.toString()), RPCService.class.getSimpleName());
//debug.print("RPC call ".concat(request.toString()), RPCService.class.getSimpleName());
return target.request().post(Entity.json(request)).readEntity(clazz);
}

Expand Down
2 changes: 1 addition & 1 deletion fx/src/main/resources/org/unigrid/janus/view/settings.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</AnchorPane>
<AnchorPane>
<children>
<Label text="Gridnode / Masternode file" textFill="#ee7722">
<Label text="Gridnode file" textFill="#ee7722">
<font>
<Font size="18.0" />
</font>
Expand Down