See the [repo root] for build status, license, rust version, etc.
Implementation of the Light Client Verification and Fork Detection protocols.
See documentation on crates.io.
The code below demonstrates the main use case for the Tendermint Light Client: syncing to the latest block, verifying it, and performing fork detection.
Please refer to the light_client
example for fully working code.
```rust let primaryinstance: Instance = makeinstance(primary, primaryaddr, primarypath); let witnessinstance: Instance = makeinstance(witness, witnessaddr, witnesspath);
let mut peeraddr = HashMap::new(); peeraddr.insert(primary, primaryaddr); peeraddr.insert(witness, witness_addr);
let peerlist = PeerList::builder() .primary(primary, primaryinstance) .witness(witness, witness_instance) .build();
let mut supervisor = Supervisor::new( peerlist, ProdForkDetector::default(), ProdEvidenceReporter::new(peeraddr), );
let mut handle = supervisor.handle();
// Spawn the supervisor in its own thread. std::thread::spawn(|| supervisor.run());
loop { // Synchronously query the supervisor via a handle let block = handle.verifytohighest();
match block {
Ok(light_block) => {
println!("[info] synced to block {}", light_block.height());
}
Err(e) => {
println!("[error] sync failed: {}", e);
}
});
std::thread::sleep(Duration::from_millis(800));
} ```