talking to testnet and painting bikeshed

This commit is contained in:
Peter Harpending 2025-09-25 22:39:07 -07:00
parent bd7c7a28b9
commit d99fefcd15
2 changed files with 89 additions and 1 deletions

View File

@ -1067,4 +1067,93 @@ So we also have to manually include all of hz's dependencies.
Thankfully, hz is also subject to this same constraint, so we only have to just
copy them from hz's zomp.meta file.
```diff
diff --git a/gex_httpd/zomp.meta b/gex_httpd/zomp.meta
index 442e32e..eb32a14 100644
--- a/gex_httpd/zomp.meta
+++ b/gex_httpd/zomp.meta
@@ -5,7 +5,18 @@
{author,"Peter Harpending"}.
{desc,"Gajumaru Exchange HTTP Daemon"}.
{package_id,{"otpr","gex_httpd",{0,1,0}}}.
-{deps,[{"otpr","hakuzaru",{0,6,1}},{"otpr","qhl",{0,1,0}}]}.
+{deps,[
+ {"otpr","hakuzaru",{0,6,1}},
+ {"otpr","sophia",{9,0,0}},
+ {"otpr","gmserialization",{0,1,3}},
+ {"otpr","gmbytecode",{3,4,1}},
+ {"otpr","base58",{0,1,1}},
+ {"otpr","eblake2",{1,0,1}},
+ {"otpr","ec_utils",{1,0,0}},
+ {"otpr","zj",{1,1,0}},
+ {"otpr","getopt",{1,0,2}},
+ {"otpr","qhl",{0,1,0}}
+]}.
{key_name,none}.
{a_email,"peterharpending@qpq.swiss"}.
{c_email,"peterharpending@qpq.swiss"}.
```
### talking to testnet
```diff
diff --git a/gex_httpd/src/gex_httpd.erl b/gex_httpd/src/gex_httpd.erl
index 3a724b0..a2ed213 100644
--- a/gex_httpd/src/gex_httpd.erl
+++ b/gex_httpd/src/gex_httpd.erl
@@ -69,10 +69,28 @@ start() ->
start(normal, _Args) ->
Result = gh_sup:start_link(),
% auto-listen to port 8000
+ ok = hz(),
ok = listen(8000),
+ ok = io:format("~p~n", [hz:status()]),
Result.
+hz() ->
+ ok = application:ensure_started(hakuzaru),
+ ok = hz:chain_nodes([testnet_node()]),
+ ok = zx:tell("hz status: ~tp", [hz:status()]),
+ ok.
+
+testnet_ip() ->
+ {84, 46, 242, 9}.
+
+testnet_port() ->
+ 3013.
+
+testnet_node() ->
+ {testnet_ip(), testnet_port()}.
+
+
-spec stop(term()) -> ok.
%% @private
%% Similar to start/2 above, this is to be called by the "application" part of OTP,
```
```erlang
hz status: {ok,#{"difficulty" => 3172644578,
"finalized" =>
#{"hash" =>
"kh_2vPQ8Q8QYQF1tSWRrSjPJ5YKSCfLD4TKEfeAvuNsdkWzVkFspp",
"height" => 215186,"type" => "height"},
"genesis_key_block_hash" =>
"kh_Qdi5MTuuhJm7xzn5JUAbYG12cX3qoLMnXrBxPGzBkMWJ4K8vq",
"hashrate" => 953086,"listening" => true,
"network_id" => "groot.testnet",
"node_revision" => "7b3cc1db3bb36053023167b86f7d6f2d5dcbd01d",
"node_version" => "0.1.0+203.7b3cc1db3",
"peer_connections" => #{"inbound" => 1,"outbound" => 3},
"peer_count" => 4,
"peer_pubkey" =>
"pp_2nQHucGyEt5wkYruNuRkg19cbZuEeyR9BZfvtv49F3AoyNSYMT",
"pending_transactions_count" => 0,
"protocols" => [#{"effective_at_height" => 0,"version" => 1}],
"solutions" => 0,"sync_progress" => 100.0,"syncing" => false,
"top_block_height" => 215287,
"top_hash" =>
"kh_2TX5p81WtTX3y82NPdfWwv7yuehDh6aMRh1Uy6GBS5JsdkaGXu",
"top_key_block_hash" =>
"kh_2TX5p81WtTX3y82NPdfWwv7yuehDh6aMRh1Uy6GBS5JsdkaGXu"}}
```

View File

@ -71,7 +71,6 @@ start(normal, _Args) ->
% auto-listen to port 8000
ok = hz(),
ok = listen(8000),
ok = io:format("~p~n", [hz:status()]),
Result.