pub struct LightClient { /* private fields */ }Expand description
Light client that verifies block headers against a trusted validator set.
Implementations§
Source§impl LightClient
impl LightClient
Sourcepub fn new(
trusted_validator_set: ValidatorSet,
trusted_height: Height,
chain_id_hash: [u8; 32],
) -> Self
pub fn new( trusted_validator_set: ValidatorSet, trusted_height: Height, chain_id_hash: [u8; 32], ) -> Self
Create a new light client with a trusted validator set and height.
Sourcepub fn verify_header(
&self,
header: &BlockHeader,
qc: &QuorumCertificate,
verifier: &dyn Verifier,
) -> Result<()>
pub fn verify_header( &self, header: &BlockHeader, qc: &QuorumCertificate, verifier: &dyn Verifier, ) -> Result<()>
Verify a block header against the given QC and the trusted validator set.
Checks:
- QC’s block_hash matches the header’s hash
- The QC has quorum (>= 2f+1 voting power)
- The QC’s aggregate signature is valid against the validator set
Sourcepub fn update_validator_set(&mut self, new_vs: ValidatorSet, new_height: Height)
pub fn update_validator_set(&mut self, new_vs: ValidatorSet, new_height: Height)
Update the trusted validator set after an epoch transition.
Sourcepub fn trusted_height(&self) -> Height
pub fn trusted_height(&self) -> Height
Return the current trusted height.
Sourcepub fn trusted_validator_set(&self) -> &ValidatorSet
pub fn trusted_validator_set(&self) -> &ValidatorSet
Return a reference to the current trusted validator set.
Auto Trait Implementations§
impl Freeze for LightClient
impl RefUnwindSafe for LightClient
impl Send for LightClient
impl Sync for LightClient
impl Unpin for LightClient
impl UnsafeUnpin for LightClient
impl UnwindSafe for LightClient
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