Skip to content

Commit

Permalink
Update client end height at the end of the service
Browse files Browse the repository at this point in the history
  • Loading branch information
nkostoulas committed Feb 19, 2020
1 parent 0876f31 commit bdeaff6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/challenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ pub fn update_challenge_request_state<K: ClientChain, D: Storage>(
// Calculate and set request's end_blockheight_clientchain
challenge.request.end_blockheight_clientchain = challenge.request.start_blockheight_clientchain
+ (service_period_time_s as f32 / block_time_clientchain as f32).floor() as u32;
storage.save_challenge_request_state(&challenge.request, &challenge.bids)?;
// Store Challenge Request and Bids
storage.save_challenge_request_state(&challenge.request, &challenge.bids)?;
}
}
Ok(())
Expand Down
9 changes: 8 additions & 1 deletion src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ pub fn run_request<T: Service, K: ClientChain, D: Storage>(
config.challenge_frequency,
time::Duration::from_secs(config.block_time / 2),
) {
Ok(()) => return Ok(Some(shared_challenge.lock().unwrap().as_ref().unwrap().request.txid)),
Ok(()) => {
// update end clientchain height with final height
let mut shared_ch_lock = shared_challenge.lock().unwrap();
let ch_final = shared_ch_lock.as_mut().unwrap();
ch_final.request.end_blockheight_clientchain = clientchain.get_blockheight()?;
storage.update_request(&ch_final.request)?;
return Ok(Some(ch_final.request.txid));
}
Err(err) => Err(err),
}
}
Expand Down

0 comments on commit bdeaff6

Please sign in to comment.