This CorDapp is a simple showcase of scheduled activities (i.e. activities started by a node at a specific time without direct input from the node owner).
A node starts its heartbeat by calling the StartHeartbeatFlow
. This creates a HeartState
on the ledger. This
HeartState
has a scheduled activity to start the HeatbeatFlow
one second later.
When the HeartbeatFlow
runs one second later, it consumes the existing HeartState
and creates a new HeartState
.
The new HeartState
also has a scheduled activity to start the HeatbeatFlow
in one second.
In this way, calling the StartHeartbeatFlow
creates an endless chain of HeartbeatFlow
s one second apart.
See https://docs.corda.net/getting-set-up.html.
The nodes do not expose a front-end or API, so you need to deploy from from the command line and interact with them via the CRaSH shell. See https://docs.corda.net/tutorial-cordapp.html#running-the-example-cordapp.
Go to the CRaSH shell for PartyA, and run the StartHeatbeatFlow
:
flow start StartHeartbeatFlow
If you now start monitoring the node's flow activity...
flow watch
...you will see the Heartbeat
flow running every second until you close the Flow Watch window using ctrl/cmd + c
:
xxxxxxxx-xxxx-xxxx-xx Heartbeat xxxxxxxxxxxxxxxxxxxx Lub-dub