Compare commits
4 Commits
925936c2f9
...
d99fefcd15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d99fefcd15 | ||
|
|
bd7c7a28b9 | ||
|
|
67252eff87 | ||
|
|
b2b973692d |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*.beam
|
*.beam
|
||||||
|
erl_crash.dump
|
||||||
|
|||||||
126
README.md
126
README.md
@ -1031,3 +1031,129 @@ index 44d206d..3abd46f 100644
|
|||||||
+slogan(404) -> "Not Found";
|
+slogan(404) -> "Not Found";
|
||||||
+slogan(500) -> "Internal Server Error".
|
+slogan(500) -> "Internal Server Error".
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Video 2: Talking to the gm testnet (2025-09-25)
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
### Adding hz as a dependency
|
||||||
|
|
||||||
|
- [`hakuzaru`](https://git.qpq.swiss/QPQ-AG/hakuzaru/) is our Erlang
|
||||||
|
\[application\] (applications are the subset of what in another language you
|
||||||
|
would call "libraries" that spawn processes, essentially...) for talking to
|
||||||
|
the blockchain from an Erlang application.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ zx list versions hakuzaru
|
||||||
|
0.6.1
|
||||||
|
0.6.0
|
||||||
|
0.5.2
|
||||||
|
0.5.1
|
||||||
|
0.5.0
|
||||||
|
0.4.0
|
||||||
|
0.3.2
|
||||||
|
0.3.1
|
||||||
|
0.3.0
|
||||||
|
0.2.0
|
||||||
|
0.1.0
|
||||||
|
$ zx set dep otpr-hakuzaru-0.6.1
|
||||||
|
```
|
||||||
|
|
||||||
|
If we just try to use this naively, we will run into errors whenever we try to
|
||||||
|
call code that calls into hz's dependencies.
|
||||||
|
|
||||||
|
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"}}
|
||||||
|
```
|
||||||
|
|||||||
BIN
etc/v001-end.png
Normal file
BIN
etc/v001-end.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
BIN
etc/v001-start.png
Normal file
BIN
etc/v001-start.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 219 KiB |
@ -69,10 +69,27 @@ start() ->
|
|||||||
start(normal, _Args) ->
|
start(normal, _Args) ->
|
||||||
Result = gh_sup:start_link(),
|
Result = gh_sup:start_link(),
|
||||||
% auto-listen to port 8000
|
% auto-listen to port 8000
|
||||||
|
ok = hz(),
|
||||||
ok = listen(8000),
|
ok = listen(8000),
|
||||||
Result.
|
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.
|
-spec stop(term()) -> ok.
|
||||||
%% @private
|
%% @private
|
||||||
%% Similar to start/2 above, this is to be called by the "application" part of OTP,
|
%% Similar to start/2 above, this is to be called by the "application" part of OTP,
|
||||||
|
|||||||
@ -5,7 +5,18 @@
|
|||||||
{author,"Peter Harpending"}.
|
{author,"Peter Harpending"}.
|
||||||
{desc,"Gajumaru Exchange HTTP Daemon"}.
|
{desc,"Gajumaru Exchange HTTP Daemon"}.
|
||||||
{package_id,{"otpr","gex_httpd",{0,1,0}}}.
|
{package_id,{"otpr","gex_httpd",{0,1,0}}}.
|
||||||
{deps,[{"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}.
|
{key_name,none}.
|
||||||
{a_email,"peterharpending@qpq.swiss"}.
|
{a_email,"peterharpending@qpq.swiss"}.
|
||||||
{c_email,"peterharpending@qpq.swiss"}.
|
{c_email,"peterharpending@qpq.swiss"}.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user