80 lines
3.6 KiB
Plaintext
80 lines
3.6 KiB
Plaintext
@author Craig Everett <craigeverett@qpq.swiss> [https://git.qpq.swiss/QPQ-AG/hakuzaru]
|
|
@version 0.8.2
|
|
@title Hakuzaru: Gajumaru blockchain bindings for Erlang
|
|
|
|
@doc
|
|
This Erlang application provides bindings for the Gajumaru blockchain and basic utilities for manipulating Gajumaru-related data.
|
|
|
|
== To Start or Not To Start ==
|
|
Starting the `hakuzaru' application is only required if you need to query the chain.
|
|
|
|
The application can be started via a call to `application', or with an explicit call to `hz:start()'.
|
|
|
|
Hakuzaru can also be run as a local application from the shell by invoking it with `zxh run hakuzaru' if you have `zx' installed.
|
|
|
|
== Operation ==
|
|
All blockchain-specific operations are accessible from the main interface modulle: `hz'
|
|
|
|
When Hakuzaru is started as an application a named process called `hz_man' is spawned that manages interactions with chain nodes, as well as a simple-one-for-one supervisor that manages the lifecycle of workers (defined in `hz_fetcher').
|
|
|
|
After startup `hz_man' must be given the address and port of a list of Gajumaru nodes that are available to service requests.
|
|
Note that the service nodes will need to have the dry-run endpoint enabled and the internal service query port made available in order to provide dry-runs and transaction submission.
|
|
|
|
When configuring chain nodes a list of nodes should be provided.
|
|
To avoid sync issues in the case of fast transaction formation/submission to the chain, only one node from the list of chain nodes is used for submitting transactions and querying `next_nonce/1`.
|
|
This node is called "the sticky node".
|
|
|
|
The first node in the list of chain nodes provided during configuration is designated as the sticky node.
|
|
If you also want to use the sticky node as a query endpoint, include it twice in the list.
|
|
|
|
The `hz_man' will round-robin requests to however many additional Gajumaru nodes are provided in the configuration.
|
|
Note that this configuration is dynamic and can be changed at runtime, so your service can adapt to node availability on the fly if needed.
|
|
|
|
```
|
|
ceverett@steak:~$ zxh run hakuzaru
|
|
Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
|
|
|
|
Eshell V15.2 (press Ctrl+G to abort, type help(). for help)
|
|
Fetching otpr-hakuzaru-0.8.2
|
|
[100.00%]
|
|
Recompile: src/hz_sup
|
|
Recompile: src/hz_man
|
|
Recompile: src/hz_key_master
|
|
Recompile: src/hz_grids
|
|
Recompile: src/hz_format
|
|
Recompile: src/hz_fetcher
|
|
Recompile: src/hz
|
|
Recompile: src/hakuzaru
|
|
Starting otpr-hakuzaru-0.8.2.
|
|
hz_man starting.
|
|
Started [hakuzaru]
|
|
1> hz:chain_nodes([{"groot.testnet.gajumaru.io", 3013}]).
|
|
ok
|
|
2> hz:status().
|
|
{ok,#{"difficulty" => 2877405482,
|
|
"finalized" =>
|
|
#{"hash" =>
|
|
"kh_PDSn6Xru5JVdpJfdDCNpfsL8gUZvvjyhTYuzgndoy98G5oLLR",
|
|
"height" => 277454,"type" => "height"},
|
|
"genesis_key_block_hash" =>
|
|
"kh_Qdi5MTuuhJm7xzn5JUAbYG12cX3qoLMnXrBxPGzBkMWJ4K8vq",
|
|
"hashrate" => 864394,"listening" => true,
|
|
"network_id" => "groot.testnet",
|
|
"node_revision" =>
|
|
"7b3cc1db3bb36053023167b86f7d6f2d5dcbd01d",
|
|
"node_version" => "0.1.0+203.7b3cc1db3",
|
|
"peer_connections" => #{"inbound" => 1,"outbound" => 3},
|
|
"peer_count" => 5,
|
|
"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" => 277555,
|
|
"top_hash" =>
|
|
"kh_2vuNc8eG77aTmHcQDcievjKufFwR4MSSuZbEMWwW5TqUzSQy71",
|
|
"top_key_block_hash" =>
|
|
"kh_2vuNc8eG77aTmHcQDcievjKufFwR4MSSuZbEMWwW5TqUzSQy71"}}
|
|
'''
|