Handler that that performs consensus algorithm.
State of the NodeHandler
.
Channel for messages and timeouts.
Redirects message to the corresponding handle_...
function.
Handles the Connected
event. Node's Connect
message is sent as response
if received Connect
message is correct.
Handles the Disconnected
event. Node will try to connect to that address again if it was
in the validators list.
Handles the UnableConnectToPeer
event. Node will try to connect to that address again
if it was in the validators list.
Handles the Connect
message and connects to a peer as result.
Handles the Status
message. Node sends BlockRequest
as response if height in the
message is higher than node's height.
Handles the PeersRequest
message. Node sends Connect
messages of other peers as result.
Handles NodeTimeout::Status
, broadcasts the Status
message if it isn't outdated as
result.
Handles NodeTimeout::PeerExchange
. Node sends the PeersRequest
to a random peer.
Handles NodeTimeout::UpdateApiState
.
Node update internal ApiState
and NodeRole
.
Broadcasts the Status
message to all peers.
Validates consensus message, then redirects it to the corresponding handle_...
function.
Handles the Propose
message. For details see the message documentation.
Handles the Block
message. For details see the message documentation.
Executes and commits block. This function is called when node has full propose information.
Executes and commits block. This function is called when node has full block information.
Panics if the received block has incorrect block_hash
.
Handles the Prevote
message. For details see the message documentation.
Locks to the propose by calling lock
. This function is called when node receives
+2/3 pre-votes.
Executes and commits block. This function is called when the node has +2/3 pre-commits.
Locks node to the specified round, so pre-votes for the lower round will be ignored.
Handles the Precommit
message. For details see the message documentation.
Commits block, so new height is achieved.
Handles raw transaction. Transaction is ignored if it is already known, otherwise it is
added to the transactions pool.
Handles raw transactions.
Handles external boxed transaction. Additionally transaction will be broadcast to the
Node's peers.
Handle new round, after jump.
Handles round timeout. As result node sends Propose
if it is a leader or Prevote
if it
is locked to some round.
Handles propose timeout. Node sends Propose
and Prevote
if it is a leader as result.
Handles request timeout by sending the corresponding request message to a peer.
Creates block with given transaction and returns its hash and corresponding changes.
Calls create_block
with transactions from the corresponding Propose
and returns the
block hash.
Returns true
if propose and all transactions are known, otherwise requests needed data
and returns false
.
Requests a block for the next height from all peers with a bigger height. Called when the
node tries to catch up with other nodes' height.
Removes the specified request from the pending request list.
Broadcasts the Prevote
message to all peers.
Broadcasts the Precommit
message to all peers.
Validates request, then redirects it to the corresponding handle_...
function.
Handles ProposeRequest
message. For details see the message documentation.
Handles TransactionsRequest
message. For details see the message documentation.
Handles PrevotesRequest
message. For details see the message documentation.
Handles BlockRequest
message. For details see the message documentation.
Creates NodeHandler
using specified Configuration
.
Return internal SharedNodeState
Returns value of the round_timeout
field from the current ConsensusConfig
.
Returns value of the status_timeout
field from the current ConsensusConfig
.
Returns value of the peers_timeout
field from the current ConsensusConfig
.
Returns value of the txs_block_limit
field from the current ConsensusConfig
.
Returns value of the minimal propose timeout.
Returns value of the maximal propose timeout.
Returns threshold starting from which the minimal propose timeout value is used.
Returns State
of the node.
Performs node initialization, so it starts consensus process from the first round.
Sends the given message to a peer by its id.
Sends the given message to a peer by its public key.
Sends RawMessage
to the specified address.
Broadcasts given message to all peers.
Performs connection to the specified network address.
Adds request timeout if it isn't already requested.
Adds NodeTimeout::Round
timeout to the channel.
Adds NodeTimeout::Propose
timeout to the channel.
Adds NodeTimeout::Status
timeout to the channel.
Adds NodeTimeout::Request
timeout with RequestData
to the channel.
Adds NodeTimeout::PeerExchange
timeout to the channel.
Adds NodeTimeout::UpdateApiState
timeout to the channel.
Returns hash of the last block.
Returns start time of the requested round.
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static