Last active
September 6, 2021 17:17
-
-
Save d4hines/97daced54291e186e753717bec64a255 to your computer and use it in GitHub Desktop.
Stable*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stable* | |
Idle* | |
# Activated by an HTTP request to the node | |
mine block -> Mining Block | |
# Activated by an HTTP request to the node | |
add peer -> Adding Peer | |
recieve error from peer -> Disconnect from Peer | |
receive P2P message -> Processing P2P Message | |
Mining Block | |
# This is where we would do hashing to show | |
# proof of work, etc. | |
finished -> Send RESPONSE_BLOCKCHAIN latest block | |
Adding Peer | |
finished -> Send QUERY_LATEST | |
Disconnect from Peer | |
# Removes peer from our pool | |
disconnect -> Stable | |
# Handles incoming websocket message | |
Processing P2P Message | |
Receive Message* | |
fail to parse -> Stable | |
receive QUERY_LATEST -> Send RESPONSE_BLOCKCHAIN latest block | |
receive QUERY_ALL -> Send RESPONSE_BLOCKCHAIN whole chain | |
receive RESPONSE_BLOCKCHAIN -> Process New Blocks | |
Send Response | |
# Sends the latest block to peers | |
Send RESPONSE_BLOCKCHAIN latest block | |
finished -> Stable | |
# Send the whole blockchain to peers | |
# Nodes will ask for this when they encounter | |
# a chain that they aren't up-to-date on. | |
Send RESPONSE_BLOCKCHAIN whole chain | |
finished -> Stable | |
# Asks for latest block from peers | |
Send QUERY_LATEST | |
finished -> Stable | |
# Broadcast the whole blockchain to peers | |
Send QUERY_ALL | |
finished -> Stable | |
# Handles any number of blocks recvd from peers | |
Process New Blocks | |
ill formed message -> Stable | |
block length is zero -> Stable | |
ill formed block -> Stable | |
our block number is higher -> Stable | |
their block number is higher -> Process Higher Block Number | |
Process Higher Block Number | |
recvd previous hash eq our latest hash -> Validate Block Hash | |
recvd previous hash neq our latest and no other blocks -> Send QUERY_ALL | |
recvd whole block chain -> Validate Whole Chain | |
Validate | |
Validate Block Hash | |
block hash is valid -> Add Block to Chain | |
block hash is invalid -> Stable | |
# Just like Validate Block Hash but | |
# starts at beginning. | |
Validate Whole Chain | |
chain is valid -> Add Block to Chain | |
chain is invalid -> Stable | |
# We received a valid block (or blocks) | |
# so we'll add them to our chain. | |
# we would also write them to storage, etc. | |
Add Block to Chain | |
finished -> Stable | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render(model){ | |
let current_state_name = model.active_states[0].name; | |
return $("h1", | |
{style: {color: "darkBlue"}}, | |
`The current state is: ${current_state_name}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment