Skip to content

Commit 8016b2a

Browse files
committed
Add state recalc feature to peer start
1 parent 2c5a366 commit 8016b2a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

convex-cli/src/main/java/convex/cli/peer/PeerStart.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public class PeerStart extends APeerCommand {
7272
@Option(names = { "--norest" }, description = "Disable REST srever.")
7373
private boolean norest;
7474

75+
@Option(names = { "--recalc" }, description = "Recalculate state from the specified block position onwards.")
76+
private Integer recalc;
77+
7578
@Option(names = { "--genesis" },
7679
defaultValue = "${env:CONVEX_GENESIS_SEED}",
7780
description = "Governance seed for network genesis. For testing use only.")
@@ -172,6 +175,8 @@ public void execute() throws InterruptedException {
172175
config.put(Keywords.SOURCE, remoteSource);
173176
config.put(Keywords.URL, url);
174177
config.put(Keywords.PORT, port);
178+
if (recalc!=null) config.put(Keywords.RECALC, recalc);
179+
175180
config.put(Keywords.BASE_URL, baseURL);
176181
if (genesisKey!=null) {
177182
if (remoteSource!=null) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,13 @@ public synchronized void launch() throws LaunchException, InterruptedException {
357357

358358
HashMap<Keyword, Object> config = getConfig();
359359

360+
360361
if (config.containsKey(Keywords.RECALC)) try {
361-
Long pos=Utils.toLong(config.get(Keywords.RECALC));
362-
executor.recalcState(pos);
362+
Object o=config.get(Keywords.RECALC);
363+
if (o!=null) {
364+
Long pos=Utils.toLong(o);
365+
executor.recalcState(pos);
366+
}
363367
} catch (Exception e) {
364368
throw new LaunchException("Launch failed to recalculate state: "+e,e);
365369
}

0 commit comments

Comments
 (0)