pub struct ConsensusVerifier { /* private fields */ }Expand description
Multi-source consensus verifier (Byzantine Fault Tolerant)
Prevents “oracle attacks” on sensor data by requiring agreement from multiple independent sources.
Implementations§
Source§impl ConsensusVerifier
impl ConsensusVerifier
Sourcepub fn new(required_sources: usize, tolerance: f64) -> Self
pub fn new(required_sources: usize, tolerance: f64) -> Self
Create a new consensus verifier
§Arguments
required_sources- Minimum sources that must agree (e.g., 3 for 2/3 majority)tolerance- Max difference from median to be considered agreeing
Sourcepub fn verify_readings(
&self,
readings: &[SensorReading],
keypairs: &[KeyPair],
) -> Result<f64>
pub fn verify_readings( &self, readings: &[SensorReading], keypairs: &[KeyPair], ) -> Result<f64>
Verify readings and return consensus value
This implements Byzantine Fault Tolerance:
- Verify each sensor signature
- Calculate median value
- Count how many sensors agree (within tolerance)
- Require minimum number of agreeing sensors
Auto Trait Implementations§
impl Freeze for ConsensusVerifier
impl RefUnwindSafe for ConsensusVerifier
impl Send for ConsensusVerifier
impl Sync for ConsensusVerifier
impl Unpin for ConsensusVerifier
impl UnwindSafe for ConsensusVerifier
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