diff --git a/contract/src/msgs/data_requests/mod.rs b/contract/src/msgs/data_requests/mod.rs index 9a822069..7f094088 100644 --- a/contract/src/msgs/data_requests/mod.rs +++ b/contract/src/msgs/data_requests/mod.rs @@ -17,7 +17,6 @@ mod tests; #[derive(Clone)] pub enum DataRequestStatus { - AwaitingCommits, Committing, Revealing, } @@ -31,7 +30,6 @@ impl<'a> PrimaryKey<'a> for &'a DataRequestStatus { fn key(&self) -> Vec { vec![Key::Ref( match self { - DataRequestStatus::AwaitingCommits => "awaiting_commits", DataRequestStatus::Committing => "committing", DataRequestStatus::Revealing => "revealing", } diff --git a/contract/src/msgs/data_requests/state.rs b/contract/src/msgs/data_requests/state.rs index 0e802e75..ace27189 100644 --- a/contract/src/msgs/data_requests/state.rs +++ b/contract/src/msgs/data_requests/state.rs @@ -50,10 +50,10 @@ pub fn insert_req(store: &mut dyn Storage, dr_id: &Hash, dr: &DataRequest) -> Re // set the status to AwaitingCommits let mut statuses = DATA_REQUESTS_BY_STATUS - .may_load(store, &DataRequestStatus::AwaitingCommits)? + .may_load(store, &DataRequestStatus::Committing)? .unwrap_or_default(); statuses.insert(*dr_id); - DATA_REQUESTS_BY_STATUS.save(store, &DataRequestStatus::AwaitingCommits, &statuses)?; + DATA_REQUESTS_BY_STATUS.save(store, &DataRequestStatus::Committing, &statuses)?; Ok(()) } @@ -61,16 +61,6 @@ pub fn insert_req(store: &mut dyn Storage, dr_id: &Hash, dr: &DataRequest) -> Re pub fn commit(store: &mut dyn Storage, dr_id: &Hash, dr: &DataRequest) -> StdResult<()> { DATA_REQUESTS.save(store, dr_id, dr)?; - // First, update the status from AwaitingCommits to Committing - update_req_status( - store, - dr_id, - &DataRequestStatus::AwaitingCommits, - &DataRequestStatus::Committing, - )?; - - // and then, if the replication factor has been reached, update the status from Committing to Revealing - // we do in this order otherwise it fails for replication factor 1 if dr.replication_factor as usize == dr.commits.len() { update_req_status( store, diff --git a/contract/src/msgs/data_requests/tests.rs b/contract/src/msgs/data_requests/tests.rs index fd22015c..91a07ea2 100644 --- a/contract/src/msgs/data_requests/tests.rs +++ b/contract/src/msgs/data_requests/tests.rs @@ -32,7 +32,7 @@ fn post_data_request() { Some(test_helpers::construct_dr(constructed_dr_id, dr_args, vec![])), received_value ); - let await_commits = state::requests_by_status(&deps.storage, &DataRequestStatus::AwaitingCommits).unwrap(); + let await_commits = state::requests_by_status(&deps.storage, &DataRequestStatus::Committing).unwrap(); assert_eq!(1, await_commits.len()); assert!(await_commits.contains(&constructed_dr_id));