Skip to content

Commit

Permalink
Minor GUI / code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Dec 6, 2024
1 parent da41dd0 commit 44b01e7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions convex-core/src/main/java/convex/core/cpos/BeliefMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public AVector<SignedData<Block>> computeWinningOrder(HashMap<Order, Double> sta
double winningVote = Double.NEGATIVE_INFINITY;
for (Map.Entry<SignedData<Block>, HashMap<AVector<SignedData<Block>>, Double>> me : blockVotes.entrySet()) {
HashMap<AVector<SignedData<Block>>, Double> agreedChains = me.getValue();
double blockVote = computeVote(agreedChains);
double blockVote = computeTotalVote(agreedChains);
if ((winningResult==null)||(blockVote > winningVote)) {
winningVote = blockVote;
winningResult = me;
Expand Down Expand Up @@ -521,7 +521,7 @@ public Long apply(Order c) {
* @param m A map of values to votes
* @return The total voting stake
*/
public static <V> double computeVote(HashMap<V, Double> m) {
public static <V> double computeTotalVote(HashMap<V, Double> m) {
double result = 0.0;
for (Map.Entry<V, Double> me : m.entrySet()) {
result += me.getValue();
Expand Down
4 changes: 2 additions & 2 deletions convex-core/src/main/java/convex/core/cpos/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ public Order withBlocks(AVector<SignedData<Block>> newBlocks) {
int n=consensusPoints.length;
if ((nblocks!=consensusPoints[0])||(nblocks<consensusPoints[n-1])) {
long[] nc=consensusPoints.clone();
nc[0]=nblocks;
for (int i=1; i<n; i++) {
nc[i]=Math.min(nc[i],nblocks);
nc[i]=Math.min(nc[i],nc[i-1]);
}
nc[0]=nblocks;
newValues=newValues.assoc(IX_CONSENSUS, Vectors.createLongs(nc));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class BeliefVotingTest {

@Test
public void testComputeVote() {
assertEquals(100.0, BeliefMerge.computeVote(Maps.hashMapOf(1, 50.0, 0, 50.0)), 0.000001);
assertEquals(0.0, BeliefMerge.computeVote(Maps.hashMapOf()), 0.000001);
assertEquals(100.0, BeliefMerge.computeTotalVote(Maps.hashMapOf(1, 50.0, 0, 50.0)), 0.000001);
assertEquals(0.0, BeliefMerge.computeTotalVote(Maps.hashMapOf()), 0.000001);
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions convex-gui/src/main/java/convex/gui/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MainGUI() {
MigLayout layout=new MigLayout("wrap 1","[fill]");
setLayout(layout);

add(new HomePanel());
add(new HomePanel(),"dock center");

ActionPanel actionPanel=new ActionPanel();
actionPanel.setLayout(new MigLayout("center,align center,fillx"));
Expand All @@ -44,7 +44,7 @@ public MainGUI() {
JComponent latticeFS=createLaunchButton("Lattice Filesystem",Toolkit.DLFS_ICON,this::launchDLFS,"Launch a DLFS file browser. EXPERIMENTAL.");
actionPanel.add(latticeFS);

JComponent terminal=createLaunchButton("Client Terminal",Toolkit.TERMINAL_ICON,this::launchTerminalClient,"Open a Convex REPL terminal, connecting to any existing network");
JComponent terminal=createLaunchButton("Terminal",Toolkit.TERMINAL_ICON,this::launchTerminalClient,"Open a Convex REPL terminal, connecting to any existing network");
actionPanel.add(terminal);

JComponent hacker=createLaunchButton("Hacker Tools",Toolkit.HACKER_ICON,this::launchTools,"Open a set of useful tools for hackers and power users.");
Expand All @@ -56,7 +56,7 @@ public MainGUI() {
JComponent www=createLaunchButton("Documentation",Toolkit.WWW_ICON,this::launchWebsite,"Go to the Convex docs website (opens web browser).");
actionPanel.add(www);

add(actionPanel);
add(actionPanel,"dock south");
}

public void launchDLFS() {
Expand Down
4 changes: 2 additions & 2 deletions convex-gui/src/main/java/convex/gui/panels/HomePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public HomePanel() {
JLabel lblWelome = new JLabel("Welcome to Convex");
lblWelome.setFont(new Font("Monospaced", Font.PLAIN, 24));
lblWelome.setHorizontalAlignment(SwingConstants.CENTER);
add(lblWelome,"dock north");
// add(lblWelome,"dock north");

add(new WorldPanel(),"align center");
add(new WorldPanel(),"dock center");
}

}
1 change: 0 additions & 1 deletion convex-gui/src/main/java/convex/gui/tools/HackerTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.concurrent.TimeoutException;

import javax.swing.JFrame;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<hc.version>5.4.1</hc.version>
<convex.version>${project.version}</convex.version>
<!--Freeze this for reproducible builds. -->
<project.build.outputTimestamp>2024-09-17T11:18:52Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-12-06T13:13:13Z</project.build.outputTimestamp>
<argLine>
--add-opens=java.base/java.util=ALL-UNNAMED
</argLine>
Expand Down

0 comments on commit 44b01e7

Please sign in to comment.