diff --git a/pom.xml b/pom.xml index 1a37142e64dcde75bec6b23cb852f4fcb0089deb..a9f439170d47e95202697423f3d2cc1dce649e8b 100644 --- a/pom.xml +++ b/pom.xml @@ -56,5 +56,12 @@ <artifactId>reflections</artifactId> <version>0.9.10</version> </dependency> + <!-- https://mvnrepository.com/artifact/org.tinyjee.jgraphx/jgraphx --> + <dependency> + <groupId>org.tinyjee.jgraphx</groupId> + <artifactId>jgraphx</artifactId> + <version>1.10.1.3</version> + </dependency> + </dependencies> </project> \ No newline at end of file diff --git a/src/main/java/fucoin/actions/control/ActionWalletGetNeighbours.java b/src/main/java/fucoin/actions/control/ActionWalletGetNeighbours.java new file mode 100644 index 0000000000000000000000000000000000000000..9b7020510bc0ccca111d909fc228ac987b35835c --- /dev/null +++ b/src/main/java/fucoin/actions/control/ActionWalletGetNeighbours.java @@ -0,0 +1,17 @@ +package fucoin.actions.control; + +import akka.actor.ActorRef; +import akka.actor.UntypedActorContext; +import fucoin.actions.ClientAction; +import fucoin.wallet.AbstractWallet; + +/** + * Ask Wallet x for his known neighbours. + */ +public class ActionWalletGetNeighbours extends ClientAction { + + @Override + protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet abstractNode) { + sender.tell(new ActionWalletGetNeighboursAnswer(abstractNode), self); + } +} diff --git a/src/main/java/fucoin/actions/control/ActionWalletGetNeighboursAnswer.java b/src/main/java/fucoin/actions/control/ActionWalletGetNeighboursAnswer.java new file mode 100644 index 0000000000000000000000000000000000000000..7de65b66780ad05013476899160c1a11c8d59251 --- /dev/null +++ b/src/main/java/fucoin/actions/control/ActionWalletGetNeighboursAnswer.java @@ -0,0 +1,38 @@ +package fucoin.actions.control; + +import akka.actor.ActorRef; +import akka.actor.UntypedActorContext; +import fucoin.actions.ClientAction; +import fucoin.wallet.AbstractWallet; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Tell + */ +public class ActionWalletGetNeighboursAnswer extends ClientAction { + + private final HashMap<String, ActorRef> neighbour; + private final String name; + + + public ActionWalletGetNeighboursAnswer(AbstractWallet wallet) { + this.neighbour = wallet.getKnownNeighbors(); + this.name = wallet.getName(); + } + + @Override + protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet abstractNode) { + + } + + public String getName() { + return name; + } + + public HashMap<String, ActorRef> getNeighbour() { + return neighbour; + } +} diff --git a/src/main/java/fucoin/actions/join/ActionJoin.java b/src/main/java/fucoin/actions/join/ActionJoin.java index 4c3e083490a38b017ea47c84e4ea8796787e5de3..0e42281d4b33c3c36dabdd71c1eacbca1fa8f6d5 100644 --- a/src/main/java/fucoin/actions/join/ActionJoin.java +++ b/src/main/java/fucoin/actions/join/ActionJoin.java @@ -6,6 +6,7 @@ import fucoin.actions.ClientAction; import fucoin.wallet.AbstractWallet; import java.util.HashMap; +import java.util.Set; import java.util.concurrent.ThreadLocalRandom; /** @@ -14,20 +15,34 @@ import java.util.concurrent.ThreadLocalRandom; public class ActionJoin extends ClientAction { private static final Integer sShareNNeighbour = 2; + private final String walletName; + + public ActionJoin(String walletName) { + this.walletName = walletName; + } + @Override protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet node) { + node.addKnownNeighbor(walletName, sender); + + if (node.getRemoteSuperVisorActor() == null) { + node.deferSendOfSuperVisorActor(sender); + } else { + sender.tell(new ActionTellSupervisor(node.getRemoteSuperVisorActor()), self); + } //Choose sShareNNeighbour to send the new wallet. HashMap<String, ActorRef> sendNeighbours = new HashMap<>(); if (node.getKnownNeighbors().size() > 0) { - String[] rndNeighbours = (String[]) node.getKnownNeighbors().keySet().toArray(); + String[] rndNeighbours = new String[node.getKnownNeighbors().size()]; + node.getKnownNeighbors().keySet().toArray(rndNeighbours); int sizeKnownNeighbours = rndNeighbours.length; for (int i = 0; i < sShareNNeighbour; i++) { String walletName = rndNeighbours[ThreadLocalRandom.current().nextInt(sizeKnownNeighbours)]; if (sendNeighbours.containsKey(walletName)) { continue; - } else if (i < sizeKnownNeighbours) { + } else if (i > sizeKnownNeighbours) { break; } else { sendNeighbours.put(walletName, node.getKnownNeighbors().get(walletName)); @@ -36,13 +51,8 @@ public class ActionJoin extends ClientAction { } //Tell the wallet the chosen wallets - ActionJoinAnswer aja = new ActionJoinAnswer(sendNeighbours); + ActionJoinAnswer aja = new ActionJoinAnswer(sendNeighbours, node.getRemoteSuperVisorActor()); sender.tell(aja, self); - if (node.getRemoteSuperVisorActor() == null) { - node.deferSendOfSuperVisorActor(sender); - } else { - sender.tell(new ActionTellSupervisor(node.getRemoteSuperVisorActor()), self); - } } } diff --git a/src/main/java/fucoin/actions/join/ActionJoinAnswer.java b/src/main/java/fucoin/actions/join/ActionJoinAnswer.java index 4a6dc153edc2a985a641089abaf9d40b9a6334f9..e3418d6149ba8854c28ba301bf082730c9d779bf 100644 --- a/src/main/java/fucoin/actions/join/ActionJoinAnswer.java +++ b/src/main/java/fucoin/actions/join/ActionJoinAnswer.java @@ -2,13 +2,10 @@ package fucoin.actions.join; import akka.actor.ActorRef; import akka.actor.UntypedActorContext; -import akka.dispatch.OnSuccess; import fucoin.actions.ClientAction; import fucoin.actions.persist.ActionSearchMyWallet; +import fucoin.supervisor.SuperVisorImpl; import fucoin.wallet.AbstractWallet; -import scala.Function1; -import scala.concurrent.Future; -import scala.runtime.BoxedUnit; import java.util.HashMap; import java.util.Map.Entry; @@ -16,7 +13,7 @@ import java.util.Map.Entry; /** * This action is the response from a wallet which is already in the network * to a wallet which wants to join the network. - * <p> + * <p/> * The node in the network sends all its known neighbours which then become * neighbours of the new node. This action also contains a reference to the * supervisor. If this is the first time the new node learned about the systems @@ -24,9 +21,11 @@ import java.util.Map.Entry; */ public class ActionJoinAnswer extends ClientAction { private final HashMap<String, ActorRef> someNeighbors; + private final ActorRef superVisor; - public ActionJoinAnswer(HashMap<String, ActorRef> someNeighbors) { + public ActionJoinAnswer(HashMap<String, ActorRef> someNeighbors, ActorRef superVisor) { this.someNeighbors = someNeighbors; + this.superVisor = superVisor; } protected void onAction(ActorRef sender, ActorRef self, @@ -34,14 +33,17 @@ public class ActionJoinAnswer extends ClientAction { wallet.addLogMsg("Addressed to " + self.path().name() + " from " + sender.path().name() + ": someNeighbors:" + someNeighbors); + //Set SuperVisor + wallet.setRemoteSuperVisorActor(superVisor); + // your neighbours? my neighbours! for (Entry<String, ActorRef> neighbor : someNeighbors.entrySet()) { wallet.addKnownNeighbor(neighbor.getKey(), neighbor.getValue()); } - /* + for (Entry<String, ActorRef> neighbor : someNeighbors.entrySet()) { neighbor.getValue().tell(new ActionSearchMyWallet(wallet.getName()), self); - }*/ + } } } diff --git a/src/main/java/fucoin/actions/join/ServerActionJoin.java b/src/main/java/fucoin/actions/join/ServerActionJoin.java index e385619fc47b9f1296ffc3c720a441d73925ffd5..8c491e5fc9310fd0f380de09b2638ab3b2e02586 100644 --- a/src/main/java/fucoin/actions/join/ServerActionJoin.java +++ b/src/main/java/fucoin/actions/join/ServerActionJoin.java @@ -21,11 +21,12 @@ public class ServerActionJoin extends SuperVisorAction { @Override protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, SuperVisorImpl node) { - ActionJoinAnswer aja = new ActionJoinAnswer(node.getKnownNeighbors()); // TODO: Might need added TellSupervisor - sender.tell(aja, self); + //ActionJoinAnswer aja = new ActionJoinAnswer(node.getKnownNeighbors()); // TODO: Might need added TellSupervisor + //sender.tell(aja, self); node.addKnownNeighbor(name, sender); + self.tell( - new ActionInvokeDistributedCommittedTransfer(self, sender, 100, self), + new ActionInvokeDistributedCommittedTransfer(self, sender, 100, node.getBankCommitObserver()), sender); } } diff --git a/src/main/java/fucoin/actions/persist/ActionInvokeRevive.java b/src/main/java/fucoin/actions/persist/ActionInvokeRevive.java index 6bfdb845aea1086ebae9c66a2449062f35f29bc3..4345876ad281aa6fbf659871890a46e26eb30da2 100644 --- a/src/main/java/fucoin/actions/persist/ActionInvokeRevive.java +++ b/src/main/java/fucoin/actions/persist/ActionInvokeRevive.java @@ -11,7 +11,7 @@ public class ActionInvokeRevive extends Persist { protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet wallet) { wallet.setActive(true); - wallet.getPreKnownNeighbour().tell(new ActionJoin(), self); + wallet.getPreKnownNeighbour().tell(new ActionJoin(wallet.getName()), self); } } diff --git a/src/main/java/fucoin/actions/search/ActionSearchWalletReference.java b/src/main/java/fucoin/actions/search/ActionSearchWalletReference.java index 9d0727acf966413757518c861ea2870ea7a67b22..900d4fb4dc54950a9a9731f7499ab0781798037e 100644 --- a/src/main/java/fucoin/actions/search/ActionSearchWalletReference.java +++ b/src/main/java/fucoin/actions/search/ActionSearchWalletReference.java @@ -23,6 +23,9 @@ public class ActionSearchWalletReference extends Search { @Override protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet wallet) { + if (sender.equals(self)) { + return; + } wallet.addLogMsg(wallet.getKnownNeighbors() + "contains " + name + "?"); ttl.add(self); ActionSearchWalletReferenceAnswer answer = null; diff --git a/src/main/java/fucoin/actions/transaction/ActionCommitDistributedCommittedTransfer.java b/src/main/java/fucoin/actions/transaction/ActionCommitDistributedCommittedTransfer.java index 641fc121d4a38b970df45fb99e3d9c179bc56ad6..f44d08498f311f0aae27f00d2ce150c47a11ebd3 100644 --- a/src/main/java/fucoin/actions/transaction/ActionCommitDistributedCommittedTransfer.java +++ b/src/main/java/fucoin/actions/transaction/ActionCommitDistributedCommittedTransfer.java @@ -52,10 +52,6 @@ public class ActionCommitDistributedCommittedTransfer extends ClientAction { } else if (target.compareTo(self) == 0) { wallet.setAmount(wallet.getAmount() + amount); wallet.addTransactionLogMessageSuccess("Received " + amount + " FUC from " + source.path().name()); - // recipient should notify a possible observer - if (observer != null) { - observer.tell(new ActionNotifyObserver(source, target, amount, granted, timestamp, id), self); - } } } else { @@ -69,12 +65,13 @@ public class ActionCommitDistributedCommittedTransfer extends ClientAction { if (source.compareTo(self) == 0) { wallet.addTransactionLogMessageFail("Failed to send " + amount + " FUC to " + target.path().name() + " (Commit has not been granted)"); - if (observer != null) { - observer.tell(new ActionNotifyObserver(source, target, amount, granted, timestamp, id), self); - } } } + // recipient should notify a possible observer + if (observer != null) { + observer.tell(new ActionNotifyObserver(source, target, amount, granted, timestamp, id), self); + } //wallet.addLogMsg("wallet.amounts:" + wallet.amounts); } diff --git a/src/main/java/fucoin/actions/transaction/ActionInvokeSentMoney.java b/src/main/java/fucoin/actions/transaction/ActionInvokeSentMoney.java index 9f7c2f25a5b8202f92506c9800de0218fe810dd1..81fa556b6da8247929ca4eed973a83f52ebfce58 100644 --- a/src/main/java/fucoin/actions/transaction/ActionInvokeSentMoney.java +++ b/src/main/java/fucoin/actions/transaction/ActionInvokeSentMoney.java @@ -23,9 +23,12 @@ public class ActionInvokeSentMoney extends Transaction { wallet.addLogMsg(wallet.getKnownNeighbors() + ""); if (wallet.getKnownNeighbors().containsKey(name)) { wallet.getRemoteSuperVisorActor().tell( - new ActionInvokeDistributedCommittedTransfer(self, wallet.getKnownNeighbors().get(name), amount, observer), sender); + new ActionInvokeDistributedCommittedTransfer(self, wallet.getKnownNeighbors().get(name), + amount, observer), sender); } else { + //Search the wallet ActionSearchWalletReference aswr = new ActionSearchWalletReference(name); + //Ask all neighbors for (ActorRef neighbor : wallet.getKnownNeighbors().values()) { neighbor.tell(aswr, self); } diff --git a/src/main/java/fucoin/configurations/AbstractConfiguration.java b/src/main/java/fucoin/configurations/AbstractConfiguration.java index 8493704af98937d47688ad0b57323902394e0d8d..5be8b9aba2c8e7a0b2dc15873033acb66fc7c220 100644 --- a/src/main/java/fucoin/configurations/AbstractConfiguration.java +++ b/src/main/java/fucoin/configurations/AbstractConfiguration.java @@ -6,10 +6,13 @@ import akka.pattern.Patterns; import akka.util.Timeout; import fucoin.AbstractNode; import fucoin.actions.control.ActionAnnounceWalletCreation; +import fucoin.actions.control.ActionWalletGetNeighbours; +import fucoin.actions.control.ActionWalletGetNeighboursAnswer; import fucoin.actions.control.ActionWalletSendMoney; import fucoin.actions.join.ActionTellSupervisor; import fucoin.actions.transaction.ActionGetAmount; import fucoin.actions.transaction.ActionGetAmountAnswer; +import fucoin.actions.transaction.ActionInvokeDistributedCommittedTransfer; import fucoin.actions.transaction.ActionNotifyObserver; import fucoin.configurations.internal.ConfigurationCreator; import fucoin.supervisor.SuperVisorImpl; @@ -69,9 +72,13 @@ public abstract class AbstractConfiguration extends AbstractNode { activeActors.add(actorRef); - if (numOfWallets == 0) { - actorRef.tell(new ActionTellSupervisor(superVisor), superVisor); - } + //if (numOfWallets == 0) { + actorRef.tell(new ActionTellSupervisor(superVisor), superVisor); + /* + superVisor.tell( new ActionInvokeDistributedCommittedTransfer(superVisor, + actorRef, 100, superVisor), actorRef); + */ + //} return actorRef; } @@ -126,13 +133,27 @@ public abstract class AbstractConfiguration extends AbstractNode { Collections.shuffle(wallets); ActorRef sender = wallets.get(0); - ActorRef recipient = wallets.get(1); + //Choose a random neighbour from sender + ActorRef recipient = null; + Future<Object> futureNeighbour = Patterns.ask(sender, new ActionWalletGetNeighbours(), timeout); + ActionWalletGetNeighboursAnswer neighboursAnswer = (ActionWalletGetNeighboursAnswer) Await.result(futureNeighbour, + timeout.duration()); + for (int i=1; i < wallets.size(); i++) { + if (neighboursAnswer.getNeighbour().containsValue(wallets.get(i))) { + recipient = wallets.get(i); + } + } + + //cancel here when no neighbour was found. + if (recipient == null) { + return; + } Future<Object> future = Patterns.ask(sender, new ActionGetAmount(), timeout); ActionGetAmountAnswer answer = (ActionGetAmountAnswer) Await.result(future, timeout.duration()); - int transferAmount = 1 + ThreadLocalRandom.current().nextInt(answer.amount); + int transferAmount = 1 + ThreadLocalRandom.current().nextInt(answer.amount - 1); sender.tell(new ActionWalletSendMoney(recipient.path().name(), transferAmount, self()), self()); } @@ -143,7 +164,7 @@ public abstract class AbstractConfiguration extends AbstractNode { */ ActorRef initSupervisor() { superVisor = context().actorOf(SuperVisorImpl.props(), "SuperVisorImpl"); - + superVisor.tell(new ActionAnnounceWalletCreation(1, self()), self()); // Don't ask. try { Thread.sleep(200); diff --git a/src/main/java/fucoin/configurations/MassWalletConfiguration.java b/src/main/java/fucoin/configurations/MassWalletConfiguration.java index fcaaadf3cea173e7b0cf3fa6fc038fbee5dcecae..bbcd338eab884d3d2fe50ce89ba0d92b1182e93d 100644 --- a/src/main/java/fucoin/configurations/MassWalletConfiguration.java +++ b/src/main/java/fucoin/configurations/MassWalletConfiguration.java @@ -1,5 +1,6 @@ package fucoin.configurations; +import fucoin.actions.transaction.ActionNotifyObserver; import fucoin.configurations.internal.ConfigurationName; /** @@ -11,8 +12,9 @@ public class MassWalletConfiguration extends AbstractConfiguration { public void run() { initSupervisor(); try { - spawnWallets(200, false); + spawnWallets(20, false); System.out.println("Wallet spawning done!"); + Thread.sleep(4000); } catch (Exception e) { System.out.println("Wallet spawning timed out!"); } diff --git a/src/main/java/fucoin/gui/SuperVisorGraphGUI.java b/src/main/java/fucoin/gui/SuperVisorGraphGUI.java new file mode 100644 index 0000000000000000000000000000000000000000..4ef3e87092b8e0cf792aa591d96bce88aa4ba98b --- /dev/null +++ b/src/main/java/fucoin/gui/SuperVisorGraphGUI.java @@ -0,0 +1,71 @@ +package fucoin.gui; + +import akka.actor.ActorRef; +import com.mxgraph.swing.mxGraphComponent; +import com.mxgraph.view.mxGraph; + +import javax.swing.*; +import java.util.*; + +/** + * + */ +public class SuperVisorGraphGUI extends JFrame { + + private SuperVisorGuiControlImpl superVisorGuiControl; + + private static final int width = 1200; + private static final int height = 800; + private static final int margin = 100; + private static final int radius = (width - margin * 2) / 3; + private static final int centerX = ((width - margin * 2) / 2) + (margin / 2); + private static final int centerY = ((height - margin * 2) / 2) + (margin / 2); + + private HashMap<String, Object> vertex = new HashMap<>(); + + public SuperVisorGraphGUI(SuperVisorGuiControlImpl superVisorGuiControl) { + super("Distributed Network Graph"); + this.superVisorGuiControl = superVisorGuiControl; + setVisible(true); + setSize(width, height); + } + + public void init() { + mxGraph graph = new mxGraph(); + Object parent = graph.getDefaultParent(); + + graph.getModel().beginUpdate(); + try { + Vector rows = superVisorGuiControl.getAmountTableModel().getDataVector(); + int numberOfWallets = rows.size(); + double rad = Math.PI * 2 / numberOfWallets; + for (int i = 0; i < numberOfWallets; i++) { + if (rows.get(i) instanceof Vector) { + Vector<Object> row = (Vector<Object>) rows.get(i); + long[] p = getPointOnCircle(rad * i); + vertex.put((String) row.get(1), graph.insertVertex(parent, + (String) row.get(1), (String) row.get(1) + "\n" + String.valueOf(row.get(2)), + p[0], p[1], //x, y, + 80, 30) //width, height + ); + } + } + + for (Map.Entry<String, HashMap<String, ActorRef>> item1 : + superVisorGuiControl.getNodeNeighbourList().entrySet()) { + for (Map.Entry<String, ActorRef> item2: item1.getValue().entrySet()) { + graph.insertEdge(parent, null, "", vertex.get(item1.getKey()), vertex.get(item2.getKey())); + } + } + } finally { + graph.getModel().endUpdate(); + } + + mxGraphComponent graphComponent = new mxGraphComponent(graph); + getContentPane().add(graphComponent); + } + + private static long[] getPointOnCircle(double t) { + return new long[]{Math.round(radius * Math.cos(t) + centerX), Math.round(radius * Math.sin(t) + centerY)}; + } +} diff --git a/src/main/java/fucoin/gui/SuperVisorGuiControlImpl.java b/src/main/java/fucoin/gui/SuperVisorGuiControlImpl.java index b0c9a125e68a2cadce66c418126fa563e9aec6bc..333ba6cd1427fc0008fa8f5bb9aa1df2725b10fe 100644 --- a/src/main/java/fucoin/gui/SuperVisorGuiControlImpl.java +++ b/src/main/java/fucoin/gui/SuperVisorGuiControlImpl.java @@ -1,21 +1,27 @@ package fucoin.gui; +import akka.actor.ActorRef; +import akka.pattern.Patterns; +import akka.util.Timeout; +import fucoin.actions.control.ActionWalletGetNeighbours; +import fucoin.actions.control.ActionWalletGetNeighboursAnswer; import fucoin.supervisor.AmountTableModel; import fucoin.supervisor.SuperVisorImpl; +import scala.concurrent.Await; +import scala.concurrent.Future; +import scala.concurrent.duration.Duration; -import javax.swing.*; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; public class SuperVisorGuiControlImpl implements SuperVisorGuiControl { private SuperVisorImpl superVisor; private AmountTableModel amountTableModel; + private HashMap<String, HashMap<String, ActorRef>> nodeNeighbours = new HashMap<>(); + private SuperVisorThreadGUI threadGUI; private boolean logActive = false; @@ -34,6 +40,28 @@ public class SuperVisorGuiControlImpl implements SuperVisorGuiControl { } + public void updateNodeNeighbourList() { + try { + Timeout timeout = new Timeout(Duration.create(10, "seconds")); + + for (Map.Entry<String, ActorRef> item : superVisor.getKnownNeighbors().entrySet()) { + Future<Object> futureNeighbour = Patterns.ask(item.getValue(), new ActionWalletGetNeighbours(), timeout); + ActionWalletGetNeighboursAnswer neighboursAnswer = (ActionWalletGetNeighboursAnswer) + Await.result(futureNeighbour, timeout.duration()); + addNodeNeighbourList(item.getKey(), neighboursAnswer.getNeighbour()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void addNodeNeighbourList(String name, HashMap<String, ActorRef> list) { + nodeNeighbours.put(name, list); + } + + public HashMap<String, HashMap<String, ActorRef>> getNodeNeighbourList() { + return nodeNeighbours; + } public void guiTerminated() { superVisor.exit(); } diff --git a/src/main/java/fucoin/gui/SuperVisorThreadGUI.java b/src/main/java/fucoin/gui/SuperVisorThreadGUI.java index d5d7a1bced7a9b4047993970268255c0ce08f765..6f6b4b064c931260664cdc8587352650307ad208 100644 --- a/src/main/java/fucoin/gui/SuperVisorThreadGUI.java +++ b/src/main/java/fucoin/gui/SuperVisorThreadGUI.java @@ -72,19 +72,32 @@ public class SuperVisorThreadGUI { frame.add(contentPanel, BorderLayout.CENTER); + JPanel btnPanel = new JPanel(); + + JButton showGraphBtn = new JButton("Show Graph"); + showGraphBtn.addActionListener(e -> { + superVisorGuiControl.updateNodeNeighbourList(); + new SuperVisorGraphGUI(superVisorGuiControl).init(); + }); + btnPanel.add(showGraphBtn); + + //Exit Button and shutdown supervisor JButton exitBtn = new JButton("Stop Supervisor"); exitBtn.addActionListener(e -> { superVisorGuiControl.guiTerminated(); frame.setVisible(false); frame.dispose(); + System.exit(0); }); if (!superVisorGuiControl.isLogActive()) { this.log(new LogMessage("Logging is currently disabled.")); } - frame.add(exitBtn, BorderLayout.PAGE_END); + btnPanel.add(exitBtn); + frame.add(btnPanel, BorderLayout.PAGE_END); + frame.setSize(800, 600); frame.setVisible(true); diff --git a/src/main/java/fucoin/wallet/WalletImpl.java b/src/main/java/fucoin/wallet/WalletImpl.java index 8b7c59d8fe4b275beae0d6693d8fd138c1d79f56..6f668e5ca3b84e3f92a1dca369cecb208061e749 100644 --- a/src/main/java/fucoin/wallet/WalletImpl.java +++ b/src/main/java/fucoin/wallet/WalletImpl.java @@ -89,13 +89,15 @@ public class WalletImpl extends AbstractWallet { if (preKnownNeighbour != null) { addKnownNeighbor(preKnownNeighbourName, preKnownNeighbour); - preKnownNeighbour.tell(new ActionJoin(), getSelf()); + preKnownNeighbour.tell(new ActionJoin(getName()), getSelf()); + /* HashMap neighborsList = new HashMap(); neighborsList.putAll(getKnownNeighbors()); neighborsList.put(name, getSelf()); ActionJoinAnswer aja = new ActionJoinAnswer(neighborsList); preKnownNeighbour.tell(aja, getSelf()); + */ if (this.getRemoteSuperVisorActor() != null) {