Skip to content

Commit 70f17ae

Browse files
committed
hook FO configQueryInterval to custom graph create
1 parent fbf0bc1 commit 70f17ae

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

resources/networks/6_node_bitcoin/network.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ nodes:
2828
connect:
2929
- tank-0006
3030
- name: tank-0006
31-
fork_observer: true
31+
fork_observer:
32+
enabled: true
33+
configQueryInterval: 20

src/warnet/deploy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def deploy_fork_observer(directory: Path):
6969
network_file = yaml.safe_load(f)
7070

7171
# Only start if configured in the network file
72-
if not network_file.get("fork_observer", False):
72+
if not network_file.get("fork_observer", {}).get("enabled", False):
7373
return
7474

7575
namespace = get_default_namespace()
@@ -99,6 +99,7 @@ def deploy_fork_observer(directory: Path):
9999
# Create yaml string using multi-line string format
100100
override_string = override_string.strip()
101101
v = {"config": override_string}
102+
v["configQueryinterval"] = network_file.get("fork_observer", {}).get("configQueryinterval", 20)
102103
yaml_string = yaml.dump(v, default_style="|", default_flow_style=False)
103104

104105
# Dump to yaml tempfile

src/warnet/main.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,22 @@ def quickstart():
190190
type=bool,
191191
default=True,
192192
)
193+
fork_observer_query_interval = 20
194+
if fork_observer:
195+
fork_observer_query_interval = click.prompt(
196+
click.style(
197+
"\nHow often would you like fork-observer to query node status (seconds)?",
198+
fg="blue",
199+
bold=True,
200+
),
201+
type=int,
202+
default=20,
203+
)
193204

194205
click.secho("\nCreating project structure...", fg="yellow", bold=True)
195206
project_path = Path(os.path.expanduser(proj_answers["project_path"]))
196207
create_warnet_project(project_path)
208+
197209
click.secho("\nGenerating custom network...", fg="yellow", bold=True)
198210
custom_network_path = project_path / "networks" / answers["network_name"]
199211
custom_graph(
@@ -202,10 +214,17 @@ def quickstart():
202214
answers["version"],
203215
custom_network_path,
204216
fork_observer,
217+
fork_observer_query_interval,
205218
)
206219
click.secho("\nSetup completed successfully!", fg="green", bold=True)
207-
click.echo("\nRun the following command to deploy this network:")
220+
221+
click.echo(
222+
f"\nEdit the network files found in {custom_network_path} before deployment if you want to customise the network."
223+
)
224+
225+
click.echo("\nWhen you're ready, run the following command to deploy this network:")
208226
click.echo(f"warnet deploy {custom_network_path}")
227+
209228
except Exception as e:
210229
click.echo(f"{e}\n\n")
211230
click.secho(f"An error occurred while running the quick start script:\n\n{e}\n\n", fg="red")
@@ -368,7 +387,12 @@ def logs(pod_name: str, follow: bool):
368387

369388

370389
def custom_graph(
371-
num_nodes: int, num_connections: int, version: str, datadir: Path, fork_observer: bool
390+
num_nodes: int,
391+
num_connections: int,
392+
version: str,
393+
datadir: Path,
394+
fork_observer: bool,
395+
fork_obs_query_interval: int,
372396
):
373397
datadir.mkdir(parents=False, exist_ok=False)
374398
# Generate network.yaml
@@ -400,7 +424,10 @@ def custom_graph(
400424
nodes.append(node)
401425

402426
network_yaml_data = {"nodes": nodes}
403-
network_yaml_data["fork_observer"] = fork_observer
427+
network_yaml_data["fork_observer"] = {
428+
"enabled": fork_observer,
429+
"configQueryInterval": fork_obs_query_interval,
430+
}
404431

405432
with open(os.path.join(datadir, "network.yaml"), "w") as f:
406433
yaml.dump(network_yaml_data, f, default_flow_style=False)

0 commit comments

Comments
 (0)