[−][src]Struct exonum::node::state::State
State of the NodeHandler
.
Methods
impl State
[src]
pub fn new(
validator_id: Option<ValidatorId>,
consensus_public_key: PublicKey,
consensus_secret_key: SecretKey,
service_public_key: PublicKey,
service_secret_key: SecretKey,
connect_list: ConnectList,
stored: StoredConfiguration,
connect: Signed<Connect>,
peers: HashMap<PublicKey, Signed<Connect>>,
last_hash: Hash,
last_height: Height,
height_start_time: SystemTime
) -> Self
[src]
validator_id: Option<ValidatorId>,
consensus_public_key: PublicKey,
consensus_secret_key: SecretKey,
service_public_key: PublicKey,
service_secret_key: SecretKey,
connect_list: ConnectList,
stored: StoredConfiguration,
connect: Signed<Connect>,
peers: HashMap<PublicKey, Signed<Connect>>,
last_hash: Hash,
last_height: Height,
height_start_time: SystemTime
) -> Self
Creates state with the given parameters.
pub fn validator_state(&self) -> &Option<ValidatorState>
[src]
Returns ValidatorState
if the node is validator.
pub fn validator_id(&self) -> Option<ValidatorId>
[src]
Returns validator id of the node if it is a validator. Returns None
otherwise.
pub fn renew_validator_id(&mut self, id: Option<ValidatorId>)
[src]
Updates the validator id. If there hasn't been ValidatorState
for that id, then a new
state will be created.
pub fn is_validator(&self) -> bool
[src]
Checks if the node is a validator.
pub fn is_leader(&self) -> bool
[src]
Checks if the node is a leader for the current height and round.
pub fn connect_list(&self) -> SharedConnectList
[src]
Returns node's ConnectList.
pub fn validators(&self) -> &[ValidatorKeys]
[src]
Returns public (consensus and service) keys of known validators.
pub fn config(&self) -> &StoredConfiguration
[src]
Returns StoredConfiguration
.
pub fn find_validator(&self, peer: PublicKey) -> Option<ValidatorId>
[src]
Returns validator id with a specified public key.
pub fn consensus_config(&self) -> &ConsensusConfig
[src]
Returns ConsensusConfig
.
pub fn services_config(&self) -> &BTreeMap<String, Value>
[src]
Returns BTreeMap
with service configs identified by name.
pub fn update_config(&mut self, config: StoredConfiguration)
[src]
Replaces StoredConfiguration
with a new one and updates validator id of the current node
if the new config is different from the previous one.
pub fn add_peer(&mut self, pubkey: PublicKey, msg: Signed<Connect>) -> bool
[src]
Adds the public key, address, and Connect
message of a validator.
pub fn add_connection(&mut self, pubkey: PublicKey, address: ConnectedPeerAddr)
[src]
Add connection to the connection list.
pub fn remove_peer_with_pubkey(
&mut self,
key: &PublicKey
) -> Option<Signed<Connect>>
[src]
&mut self,
key: &PublicKey
) -> Option<Signed<Connect>>
Removes a peer by the socket address. Returns Some
(connect message) of the peer if it was
indeed connected or None
if there was no connection with given socket address.
pub fn peer_is_validator(&self, pubkey: &PublicKey) -> bool
[src]
Checks if this node considers a peer to be a validator.
pub fn peer_in_connect_list(&self, pubkey: &PublicKey) -> bool
[src]
Checks if a peer is in this node's connection list.
pub fn peers(&self) -> &HashMap<PublicKey, Signed<Connect>>
[src]
Returns the keys of known peers with their Connect
messages.
pub fn connections(&self) -> &HashMap<PublicKey, ConnectedPeerAddr>
[src]
Returns the addresses of known connections with public keys of its' validators.
pub fn consensus_public_key_of(&self, id: ValidatorId) -> Option<PublicKey>
[src]
Returns public key of a validator identified by id.
pub fn consensus_public_key(&self) -> &PublicKey
[src]
Returns the consensus public key of the current node.
pub fn consensus_secret_key(&self) -> &SecretKey
[src]
Returns the consensus secret key of the current node.
pub fn service_public_key(&self) -> &PublicKey
[src]
Returns the service public key of the current node.
pub fn service_secret_key(&self) -> &SecretKey
[src]
Returns the service secret key of the current node.
pub fn leader(&self, round: Round) -> ValidatorId
[src]
Returns the leader id for the specified round and current height.
pub fn update_validator_round(
&mut self,
id: ValidatorId,
round: Round
) -> Option<Round>
[src]
&mut self,
id: ValidatorId,
round: Round
) -> Option<Round>
Updates known round for a validator and returns a new actual round if at least one non byzantine validators is guaranteed to be on a higher round. Otherwise returns None.
pub fn node_height(&self, key: &PublicKey) -> Height
[src]
Returns the height for a validator identified by the public key.
pub fn set_node_height(&mut self, key: PublicKey, height: Height)
[src]
Updates known height for a validator identified by the public key.
pub fn nodes_with_bigger_height(&self) -> Vec<&PublicKey>
[src]
Returns a list of nodes whose height is bigger than one of the current node.
pub fn majority_count(&self) -> usize
[src]
Returns sufficient number of votes for current validators number.
pub fn byzantine_majority_count(total: usize) -> usize
[src]
Returns sufficient number of votes for the given validators number.
pub fn height(&self) -> Height
[src]
Returns current height.
pub fn height_start_time(&self) -> SystemTime
[src]
Returns start time of the current height.
pub fn round(&self) -> Round
[src]
Returns the current round.
pub fn last_hash(&self) -> &Hash
[src]
Returns a hash of the last block.
pub fn lock(&mut self, round: Round, hash: Hash)
[src]
Locks the node to the specified round and propose hash.
Panics
Panics if the current "locked round" is bigger or equal to the new one.
pub fn locked_round(&self) -> Round
[src]
Returns locked round number. Zero means that the node is not locked to any round.
pub fn locked_propose(&self) -> Option<Hash>
[src]
Returns propose hash on which the node makes lock.
pub fn propose_mut(&mut self, hash: &Hash) -> Option<&mut ProposeState>
[src]
Returns mutable propose state identified by hash.
pub fn propose(&self, hash: &Hash) -> Option<&ProposeState>
[src]
Returns propose state identified by hash.
pub fn block(&self, hash: &Hash) -> Option<&BlockState>
[src]
Returns a block with the specified hash.
pub fn jump_round(&mut self, round: Round)
[src]
Updates mode's round.
pub fn new_round(&mut self)
[src]
Increments node's round by one.
pub fn incomplete_block(&self) -> Option<&IncompleteBlock>
[src]
Return incomplete block.
pub fn new_height(&mut self, block_hash: &Hash, height_start_time: SystemTime)
[src]
Increments the node height by one and resets previous height data.
pub fn queued(&mut self) -> Vec<ConsensusMessage>
[src]
Returns a list of queued consensus messages.
pub fn add_queued(&mut self, msg: ConsensusMessage)
[src]
Add consensus message to the queue.
pub fn check_incomplete_proposes(&mut self, tx_hash: Hash) -> Vec<(Hash, Round)>
[src]
Checks whether some proposes are waiting for this transaction. Returns a list of proposes that don't contain unknown transactions.
Transaction is ignored if the following criteria are fulfilled:
- transaction isn't contained in unknown transaction list of any propose
- transaction isn't a part of block
pub fn remove_unknown_transaction(
&mut self,
tx_hash: Hash
) -> Option<IncompleteBlock>
[src]
&mut self,
tx_hash: Hash
) -> Option<IncompleteBlock>
Checks if there is an incomplete block that waits for this transaction. Returns a block that don't contain unknown transactions.
Transaction is ignored if the following criteria are fulfilled:
- transaction isn't contained in the unknown transactions list of block
- transaction isn't a part of block
pub fn prevotes(&self, round: Round, propose_hash: Hash) -> &[Signed<Prevote>]
[src]
Returns pre-votes for the specified round and propose hash.
pub fn precommits(
&self,
round: Round,
propose_hash: Hash
) -> &[Signed<Precommit>]
[src]
&self,
round: Round,
propose_hash: Hash
) -> &[Signed<Precommit>]
Returns pre-commits for the specified round and propose hash.
pub fn have_prevote(&self, propose_round: Round) -> bool
[src]
Returns true
if this node has pre-vote for the specified round.
Panics
Panics if this method is called for a non-validator node.
pub fn add_self_propose(&mut self, msg: Signed<Propose>) -> Hash
[src]
Adds propose from this node to the proposes list for the current height. Such propose cannot contain unknown transactions. Returns hash of the propose.
pub fn add_propose<S: AsRef<dyn Snapshot>>(
&mut self,
msg: Signed<Propose>,
transactions: &MapIndex<S, Hash, Signed<RawTransaction>>,
transaction_pool: &KeySetIndex<S, Hash>
) -> Result<&ProposeState, Error>
[src]
&mut self,
msg: Signed<Propose>,
transactions: &MapIndex<S, Hash, Signed<RawTransaction>>,
transaction_pool: &KeySetIndex<S, Hash>
) -> Result<&ProposeState, Error>
Adds propose from other node. Returns ProposeState
if it is a new propose.
pub fn add_block(
&mut self,
block_hash: Hash,
patch: Patch,
txs: Vec<Hash>,
proposer_id: ValidatorId
) -> Option<&BlockState>
[src]
&mut self,
block_hash: Hash,
patch: Patch,
txs: Vec<Hash>,
proposer_id: ValidatorId
) -> Option<&BlockState>
Adds block to the list of blocks for the current height. Returns BlockState
if it is a
new block.
pub fn create_incomplete_block<S: AsRef<dyn Snapshot>>(
&mut self,
msg: &Signed<BlockResponse>,
txs: &MapIndex<S, Hash, Signed<RawTransaction>>,
txs_pool: &KeySetIndex<S, Hash>
) -> &IncompleteBlock
[src]
&mut self,
msg: &Signed<BlockResponse>,
txs: &MapIndex<S, Hash, Signed<RawTransaction>>,
txs_pool: &KeySetIndex<S, Hash>
) -> &IncompleteBlock
Finds unknown transactions in the block and persists transactions along with other info as a pending block.
Panics
- Already there is an incomplete block.
- Received block has already committed transaction.
pub fn add_prevote(&mut self, msg: Signed<Prevote>) -> bool
[src]
Adds pre-vote. Returns true
there are +2/3 pre-votes.
Panics
A node panics if it has already sent a different Prevote
for the same round.
pub fn has_majority_prevotes(&self, round: Round, propose_hash: Hash) -> bool
[src]
Returns true
if there are +2/3 pre-votes for the specified round and hash.
pub fn known_prevotes(&self, round: Round, propose_hash: &Hash) -> BitVec
[src]
Returns ids of validators that that sent pre-votes for the specified propose.
pub fn known_precommits(&self, round: Round, propose_hash: &Hash) -> BitVec
[src]
Returns ids of validators that that sent pre-commits for the specified propose.
pub fn add_precommit(&mut self, msg: Signed<Precommit>) -> bool
[src]
Adds pre-commit. Returns true
there are +2/3 pre-commits.
Panics
A node panics if it has already sent a different Precommit
for the same round.
pub fn add_unknown_propose_with_precommits(
&mut self,
round: Round,
propose_hash: Hash,
block_hash: Hash
)
[src]
&mut self,
round: Round,
propose_hash: Hash,
block_hash: Hash
)
Adds unknown (for this node) propose.
pub fn take_unknown_propose_with_precommits(
&mut self,
propose_hash: &Hash
) -> Vec<(Round, Hash)>
[src]
&mut self,
propose_hash: &Hash
) -> Vec<(Round, Hash)>
Removes propose from the list of unknown proposes and returns its round and hash.
pub fn has_majority_precommits(&self, round: Round, block_hash: Hash) -> bool
[src]
Returns true if the node has +2/3 pre-commits for the specified round and block hash.
pub fn have_incompatible_prevotes(&self) -> bool
[src]
Returns true
if the node doesn't have proposes different from the locked one.
pub fn request(&mut self, data: RequestData, peer: PublicKey) -> bool
[src]
Adds data-request to the queue. Returns true
if it is a new request.
pub fn retry(
&mut self,
data: &RequestData,
peer: Option<PublicKey>
) -> Option<PublicKey>
[src]
&mut self,
data: &RequestData,
peer: Option<PublicKey>
) -> Option<PublicKey>
Returns public key of a peer that has required information. Returned key is removed from the corresponding validators list, so next time request will be sent to a different peer.
pub fn remove_request(&mut self, data: &RequestData) -> HashSet<PublicKey>
[src]
Removes the specified request from the pending request list.
pub fn our_connect_message(&self) -> &Signed<Connect>
[src]
Returns the Connect
message of the current node.
pub fn set_our_connect_message(&mut self, msg: Signed<Connect>)
[src]
Updates the Connect
message of the current node.
pub fn add_peer_to_connect_list(&mut self, peer: ConnectInfo)
[src]
Add peer to node's ConnectList
.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T> Same for T
type Output = T
Should always be Self