Last active
September 6, 2021 20:31
-
-
Save d4hines/f7a59a89f21abe1db98081fbe62112ae 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. | |
do proof of work -> 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 -> Ignore Message | |
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 -> Ignore Message | |
block length is zero -> Ignore Message | |
ill formed block -> Ignore Message | |
our block number is higher -> Ignore Message | |
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 -> Validate Timestamp | |
block hash is invalid -> Ignore Message | |
Validate Timestamp | |
valid? -> Stable | |
invalid? -> Ignore Message | |
# Just like Validate Block Hash but | |
# starts at beginning and validates each block. | |
# We represent this in a hand-wavey way with | |
# a transition to Validate Block Hash | |
Validate Whole Chain | |
chain is valid -> Validate Block Hash | |
chain is invalid -> Stable | |
Ignore Message | |
back to stable -> 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