From d382596c7fcfc47946a15558ca20beec3d178ec6 Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Tue, 15 Oct 2024 21:55:18 +0900 Subject: [PATCH] WIP --- include/gmc.hrl | 2 +- src/clutch.erl | 1 + src/gmc_con.erl | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/gmc.hrl b/include/gmc.hrl index 9cc2cff..1cb3b22 100644 --- a/include/gmc.hrl +++ b/include/gmc.hrl @@ -2,7 +2,7 @@ -record(node, {ip = {161,97,102,143} :: string() | inet:ip_address(), - external = 3013 :: inet:port_number(), % 3013 + external = 3013 :: none | inet:port_number(), % 3013 internal = none :: none | inet:port_number(), % 3113 rosetta = none :: none | inet:port_number(), % 8080 channel = none :: none | inet:port_number(), % 3014 diff --git a/src/clutch.erl b/src/clutch.erl index 6af78ae..25db1ca 100644 --- a/src/clutch.erl +++ b/src/clutch.erl @@ -55,6 +55,7 @@ start(normal, _Args) -> ok = tell(error, "DANGER! This node is in distributed mode!"), init:stop(1) end, + ok = application:ensure_started(hakuzaru), ok = application:ensure_started(zxwidgets), gmc_sup:start_link(). diff --git a/src/gmc_con.erl b/src/gmc_con.erl index 06ccbe2..da15d6e 100644 --- a/src/gmc_con.erl +++ b/src/gmc_con.erl @@ -381,7 +381,7 @@ do_show_ui(Name, State = #s{tasks = Tasks, prefs = Prefs, wallet = Wallet}) -> end. -do_chain(ID, State = #s{prefs = Prefs}) -> +do_chain(_, State) -> tell("Would be doing chain in do_chain/2 here"), State. @@ -522,8 +522,14 @@ do_add_node(New, State) -> State. -do_set_sole_node(TheOneTrueNode, State) -> - tell("TheOneTrueNode: ~p", [TheOneTrueNode]), +% FIXME: This will, of course, totally explode if anything goes wrong +do_set_sole_node(TOTN = #node{external = none}, State) -> + do_set_sole_node(TOTN#node{external = 3013}, State); +do_set_sole_node(#node{ip = Address, external = Port}, State) -> + ok = hz:chain_nodes([{Address, Port}]), + {ok, Status = #{"network_id" := NetworkID}} = hz:status(), + ok = hz:network_id(NetworkID), + tell("Status: ~p", [Status]), State.