Skip to content

Commit 628656e

Browse files
committed
GUI tweaks
1 parent d99ed3f commit 628656e

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

convex-gui/src/main/java/convex/gui/components/account/AccountChooserPanel.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
import javax.swing.JPanel;
1010
import javax.swing.JPopupMenu;
1111

12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
1215
import convex.api.Convex;
1316
import convex.core.crypto.AKeyPair;
1417
import convex.core.crypto.wallet.AWalletEntry;
15-
import convex.core.cvm.ops.Special;
16-
import convex.core.data.AccountKey;
1718
import convex.core.cvm.Address;
1819
import convex.core.cvm.Symbols;
20+
import convex.core.cvm.ops.Special;
21+
import convex.core.data.AccountKey;
1922
import convex.core.exceptions.ResultException;
2023
import convex.gui.components.BalanceLabel;
2124
import convex.gui.components.DropdownMenu;
@@ -29,6 +32,9 @@
2932
*/
3033
@SuppressWarnings("serial")
3134
public class AccountChooserPanel extends JPanel {
35+
36+
private static final Logger log = LoggerFactory.getLogger(AccountChooserPanel.class.getName());
37+
3238

3339
private JComboBox<String> modeCombo;
3440
public final AddressCombo addressCombo;
@@ -119,6 +125,17 @@ public AccountChooserPanel(Convex convex) {
119125
convex.clearSequence();
120126
});
121127
popupMenu.add(setSeqButton);
128+
129+
JMenuItem reconnectButton = new JMenuItem("Reconnect",Toolkit.menuIcon(0xe9d5));
130+
reconnectButton.addActionListener(e -> {
131+
try {
132+
convex.reconnect();
133+
} catch (Exception ex) {
134+
log.info("Reconnect failed",ex);
135+
}
136+
});
137+
popupMenu.add(reconnectButton);
138+
122139

123140

124141
DropdownMenu dm = new DropdownMenu(popupMenu,Toolkit.SMALL_ICON_SIZE);
@@ -169,6 +186,7 @@ public void updateAddress(Address a) {
169186
}
170187

171188
public void setKeyPair(AWalletEntry we) {
189+
System.err.println("Setting wallet entry:" +we);
172190
if (we==null) {
173191
convex.setKeyPair(null);
174192
} else {

convex-gui/src/main/java/convex/gui/repl/REPLPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private void sendMessage(String s) {
335335
output.append(" TIMEOUT waiting for result\n",Color.RED);
336336
} catch (IllegalStateException t) {
337337
// General errors we understand
338-
output.append(" ERROR: ",Color.RED);
338+
output.append(" EXCEPTION: ",Color.RED);
339339
output.append(t.getMessage() + "\n");
340340
} catch (Exception t) {
341341
// Something bad.....

convex-java/src/main/java/convex/java/ConvexHTTP.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package convex.java;
22

3+
import java.io.IOException;
34
import java.net.InetSocketAddress;
45
import java.net.URI;
56
import java.util.concurrent.CompletableFuture;
7+
import java.util.concurrent.TimeoutException;
68

79
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
810
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
@@ -182,4 +184,9 @@ public InetSocketAddress getHostAddress() {
182184
return new InetSocketAddress(uri.getHost(),port);
183185
}
184186

187+
@Override
188+
public void reconnect() throws IOException, TimeoutException, InterruptedException {
189+
// Nothing to do?
190+
}
191+
185192
}

convex-peer/src/main/java/convex/api/Convex.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,4 +1027,6 @@ public void clearSequence() {
10271027
this.sequence=null;
10281028
}
10291029

1030+
public abstract void reconnect() throws IOException, TimeoutException, InterruptedException;
1031+
10301032
}

convex-peer/src/main/java/convex/api/ConvexLocal.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.net.InetSocketAddress;
55
import java.util.concurrent.CompletableFuture;
6+
import java.util.concurrent.TimeoutException;
67
import java.util.function.Predicate;
78

89
import convex.core.ErrorCodes;
@@ -210,6 +211,11 @@ public Long getBalance() {
210211
return server.getPeer().getConsensusState().getBalance(address);
211212
}
212213

214+
@Override
215+
public void reconnect() {
216+
// Always connected, basically
217+
}
218+
213219

214220

215221
}

convex-peer/src/main/java/convex/peer/TransactionHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ void maybeGetOwnTransactions(Peer p) {
398398

399399
// If we already posted own transaction recently, don't try again
400400
if (ts<(lastOwnTransactionTimestamp+OWN_BLOCK_DELAY)) return;
401-
lastOwnTransactionTimestamp=ts; // mark this timestamp
402401

403402
// NOTE: beyond this point we only execute stuff when AUTO_MANAGE is set
404403
if (!Utils.bool(server.getConfig().get(Keywords.AUTO_MANAGE))) return;
@@ -410,7 +409,8 @@ void maybeGetOwnTransactions(Peer p) {
410409
AccountKey peerKey=p.getPeerKey();
411410
PeerStatus ps=s.getPeer(peerKey);
412411
if (ps==null) return; // No peer record in consensus state?
413-
412+
413+
414414
AString chn=ps.getHostname();
415415
String currentHostname=(chn==null)?null:chn.toString();
416416
String desiredHostname=server.getHostname(); // Intended hostname
@@ -432,6 +432,7 @@ void maybeGetOwnTransactions(Peer p) {
432432
ACell message = Reader.read(code);
433433
ATransaction transaction = Invoke.create(address, as.getSequence()+1, message);
434434
newTransactions.add(p.getKeyPair().signData(transaction));
435+
lastOwnTransactionTimestamp=ts; // mark this timestamp
435436
}
436437
}
437438

0 commit comments

Comments
 (0)