This example connects to an Ephemera node.
- Submits signed messages to the node
- Listens WS for new blocks
- Queries the node for received blocks over http API and compares them with the ones received via WS
- Verifies the signatures of the blocks
- Verifies the signatures of the messages in the blocks
../../scripts/local-cluster init -n 3
PS! By default, all nodes produce blocks. To turn it off for a node, edit configuration:
[block_config]
producer = false
From the top-level directory:
../../scripts/local-cluster run -a ephemera
cargo run -- --help
Ephemera http and ws external interfaces example
Usage: ephemera-http-ws-example [OPTIONS] --host <HOST> --http-port <HTTP_PORT> --ws-port <WS_PORT>
Options:
--host <HOST>
--http-port <HTTP_PORT>
--ws-port <WS_PORT>
--messages-frequency-ms <MESSAGES_FREQUENCY_MS>
[default: 1000]
--block-query-frequency-sec <BLOCK_QUERY_FREQUENCY_SEC>
[default: 10]
-h, --help
Print help information
cargo run -- --host 127.0.0.1 --http-port 7001 --ws-port 6001 --messages-frequency-ms 10000
../../scripts/local-cluster stop
Connecting to ephemera node on 127.0.0.1
Querying new blocks 10 ms
Listening to ws blocks on ws://127.0.0.1:6001
Sending messages to http://127.0.0.1:7001
Sending signed messages every 10000 ms
Received new block
Received nr of blocks: 1
Block found by hash: "aFEUaCYfP8iBNwQy3EVjgfE1LmojibGr56Q9vx39cuu"
Comparing block aFEUaCYfP8iBNwQy3EVjgfE1LmojibGr56Q9vx39cuu
Block header match
Comparing block messages, count: 103
Block messages match
Verifying messages signatures: 103
All messages signatures are valid
Block certificates found by hash: "aFEUaCYfP8iBNwQy3EVjgfE1LmojibGr56Q9vx39cuu", len 6
Verifying block certificates: 6
Certificate from peer 12D3KooWQrvPUr9kFM8KkVoWwgUT13NXaFnryVa6RzDJAxYJMnV9 is valid
Certificate from peer 12D3KooWBGdcpj361Zpez5Psjdz8U11D69wvTThphqXCLQZHxqWT is valid
Certificate from peer 12D3KooW9wcn2XUQxfeL5MRnMMpe7ickcjBz1B2aSAfbHPwjHziy is valid
Certificate from peer 12D3KooWNiJyRXhBmKmTWsvZXamedDWBS3rG3ojKKE7tcEGsttgY is valid
Certificate from peer 12D3KooWJSZzExhcoP1F2k1yBbEkkpSyMHMFFkq6KSnESU8WC334 is valid
Certificate from peer 12D3KooWRfPuqp65cKBT8d5k3ECbpVZMrbrK4GhpW2QfNxyPBuRv is valid