diff --git a/src/challenger.rs b/src/challenger.rs index 2d508f4..e24cffd 100644 --- a/src/challenger.rs +++ b/src/challenger.rs @@ -162,8 +162,8 @@ pub fn update_challenge_request_state( // 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(()) diff --git a/src/coordinator.rs b/src/coordinator.rs index d9efead..123e95b 100644 --- a/src/coordinator.rs +++ b/src/coordinator.rs @@ -118,7 +118,14 @@ pub fn run_request( 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), } }