diff --git a/iot_config/src/lib.rs b/iot_config/src/lib.rs index 83cbc4b83..dadc4531d 100644 --- a/iot_config/src/lib.rs +++ b/iot_config/src/lib.rs @@ -72,7 +72,9 @@ pub struct EpochInfo { impl From for EpochInfo { fn from(next_reward_epoch: u64) -> Self { - let start_time = DateTime::::UNIX_EPOCH + Duration::days(next_reward_epoch as i64); + let start_time = DateTime::::UNIX_EPOCH + + Duration::days(next_reward_epoch as i64) + + Duration::hours(1); let end_time = start_time + Duration::days(1); EpochInfo { period: start_time..end_time, diff --git a/iot_config/src/sub_dao_epoch_reward_info.rs b/iot_config/src/sub_dao_epoch_reward_info.rs index 63be49168..7c9c9e612 100644 --- a/iot_config/src/sub_dao_epoch_reward_info.rs +++ b/iot_config/src/sub_dao_epoch_reward_info.rs @@ -74,7 +74,7 @@ pub(crate) mod db { address AS epoch_address, sub_dao AS sub_dao_address, epoch::BIGINT, - hnt_rewards_issued::BIGINT, + delegation_rewards_issued::BIGINT as hnt_rewards_issued, delegation_rewards_issued::BIGINT, rewards_issued_at::BIGINT FROM sub_dao_epoch_infos @@ -105,11 +105,18 @@ pub(crate) mod db { .to_timestamp() .map_err(|err| sqlx::Error::Decode(Box::new(err)))?; + let hnt_rewards_issued = row.get::("hnt_rewards_issued") as u64; + if hnt_rewards_issued == 0 { + return Err(sqlx::Error::Decode(Box::new(sqlx::Error::Decode( + Box::from("hnt_rewards_issued is 0"), + )))); + }; + Ok(Self { epoch: row.try_get::("epoch")? as u64, epoch_address: row.try_get::("epoch_address")?, sub_dao_address: row.try_get::("sub_dao_address")?, - hnt_rewards_issued: row.try_get::("hnt_rewards_issued")? as u64, + hnt_rewards_issued, delegation_rewards_issued: row.try_get::("delegation_rewards_issued")? as u64, rewards_issued_at, diff --git a/iot_verifier/src/rewarder.rs b/iot_verifier/src/rewarder.rs index dee51431e..d991a83a4 100644 --- a/iot_verifier/src/rewarder.rs +++ b/iot_verifier/src/rewarder.rs @@ -107,8 +107,16 @@ where let now = Utc::now(); let sleep_duration = if scheduler.should_trigger(now) { if self.data_current_check(&scheduler.schedule_period).await? { - self.reward(next_reward_epoch).await?; - scheduler.sleep_duration(Utc::now())? + match self.reward(next_reward_epoch).await { + Ok(()) => { + tracing::info!("Successfully rewarded for epoch {}", next_reward_epoch); + scheduler.sleep_duration(Utc::now())? + } + Err(e) => { + tracing::error!("Failed to reward: {}", e); + REWARDS_NOT_CURRENT_DELAY_PERIOD + } + } } else { REWARDS_NOT_CURRENT_DELAY_PERIOD }