Struct exonum::node::state::State
[−]
[src]
pub struct State { /* fields omitted */ }
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,
tx_pool_capacity: usize,
whitelist: Whitelist,
stored: StoredConfiguration,
connect: Connect,
peers: HashMap<PublicKey, 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,
tx_pool_capacity: usize,
whitelist: Whitelist,
stored: StoredConfiguration,
connect: Connect,
peers: HashMap<PublicKey, 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 whitelist(&self) -> &Whitelist
[src]
Returns node's whitelist.
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 adjust_timeout(&mut self, snapshot: &Snapshot)
[src]
Adjusts propose timeout (see TimeoutAdjuster
for the details).
pub fn propose_timeout(&self) -> Milliseconds
[src]
Returns adjusted (see TimeoutAdjuster
for the details) value of the propose timeout.
pub fn add_peer(&mut self, pubkey: PublicKey, msg: Connect) -> bool
[src]
Adds the public key, address, and Connect
message of a validator.
pub fn remove_peer_with_addr(&mut self, addr: &SocketAddr) -> bool
[src]
Removes a peer by the socket address.
pub fn peers(&self) -> &HashMap<PublicKey, Connect>
[src]
Returns the keys of known peers with their Connect
messages.
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 get_actual_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 are 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 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 transactions(&self) -> &TxPool
[src]
Returns non-committed transactions.
pub fn add_transaction(
&mut self,
tx_hash: Hash,
msg: Box<Transaction>,
high_priority_tx: bool
) -> Vec<(Hash, Round)>
[src]
&mut self,
tx_hash: Hash,
msg: Box<Transaction>,
high_priority_tx: bool
) -> Vec<(Hash, Round)>
Adds a transaction to the pool and returns list of proposes that don't contain unknown transactions now.
Transaction is ignored if the following criteria are fulfilled:
- transactions pool size is exceeded
- transaction isn't contained in unknown transaction list of any propose
- transaction isn't a part of block
pub fn prevotes(&self, round: Round, propose_hash: Hash) -> &[Prevote]
[src]
Returns pre-votes for the specified round and propose hash.
pub fn precommits(&self, round: Round, propose_hash: Hash) -> &[Precommit]
[src]
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: 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(&mut self, msg: &Propose) -> Option<&ProposeState>
[src]
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 add_prevote(&mut self, msg: &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: &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 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) -> &Connect
[src]
Returns the Connect
message of the current node.
pub fn set_our_connect_message(&mut self, msg: Connect)
[src]
Updates the Connect
message of the current node.