pub struct ReputationSystem { /* private fields */ }Expand description
Reputation system
Implementations§
Source§impl ReputationSystem
impl ReputationSystem
pub fn new(config: ReputationConfig) -> Self
Register a new authority
Sourcepub fn get_reputation(&self, authority: &AuthorityId) -> Result<f64>
pub fn get_reputation(&self, authority: &AuthorityId) -> Result<f64>
Get authority reputation
Sourcepub fn get_entry(&self, authority: &AuthorityId) -> Result<&ReputationEntry>
pub fn get_entry(&self, authority: &AuthorityId) -> Result<&ReputationEntry>
Get reputation entry
Sourcepub fn record_correct_vote(&mut self, authority: &AuthorityId) -> Result<()>
pub fn record_correct_vote(&mut self, authority: &AuthorityId) -> Result<()>
Record correct vote
Sourcepub fn record_incorrect_vote(&mut self, authority: &AuthorityId) -> Result<()>
pub fn record_incorrect_vote(&mut self, authority: &AuthorityId) -> Result<()>
Record incorrect vote
Sourcepub fn record_timeout(&mut self, authority: &AuthorityId) -> Result<()>
pub fn record_timeout(&mut self, authority: &AuthorityId) -> Result<()>
Record timeout
Sourcepub fn record_byzantine_fault(&mut self, authority: &AuthorityId) -> Result<()>
pub fn record_byzantine_fault(&mut self, authority: &AuthorityId) -> Result<()>
Record Byzantine fault
Sourcepub fn apply_decay(&mut self)
pub fn apply_decay(&mut self)
Apply reputation decay for all authorities
Get all trustworthy authorities
Sourcepub fn calculate_weighted_reputation(
&self,
authority: &AuthorityId,
) -> Result<f64>
pub fn calculate_weighted_reputation( &self, authority: &AuthorityId, ) -> Result<f64>
Calculate weighted reputation for authority
Get authorities ranked by reputation
Sourcepub fn get_statistics(&self) -> ReputationStatistics
pub fn get_statistics(&self) -> ReputationStatistics
Get statistics
Auto Trait Implementations§
impl Freeze for ReputationSystem
impl RefUnwindSafe for ReputationSystem
impl Send for ReputationSystem
impl Sync for ReputationSystem
impl Unpin for ReputationSystem
impl UnwindSafe for ReputationSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more