Skip to content

Commit

Permalink
rename some vars and more logical bisection in cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
liamsi committed Feb 8, 2020
1 parent 57e6a27 commit 8c5a779
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions light-node/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ impl Runnable for StartCmd {
subjective_init(config.subjective_init.height, vals_hash, &mut store, &req).unwrap();

loop {
let latest = (&req).signed_header(0).unwrap();
let latest_peer_height = latest.header().height();
let latest_sh = (&req).signed_header(0).unwrap();
let latest_peer_height = latest_sh.header().height();

let latest = store.get(0).unwrap();
let latest_height = latest.last_header().header().height();
let latest_trusted = store.get(0).unwrap();
let latest_trusted_height = latest_trusted.last_header().header().height();

// only bisect to higher heights
if latest_peer_height <= latest_height {
if latest_peer_height <= latest_trusted_height {
std::thread::sleep(Duration::new(1, 0));
continue;
}

println!(
"attempting bisection from height {:?} to height {:?}",
store.get(0).unwrap().last_header().header().height(),
latest_trusted_height,
latest_peer_height,
);

let now = &SystemTime::now();
lite::verify_bisection(
latest.to_owned(),
latest_height,
latest_trusted.to_owned(),
latest_peer_height,
TrustThresholdFraction::default(), // TODO
&config.trusting_period,
now,
Expand Down

0 comments on commit 8c5a779

Please sign in to comment.