Skip to content

Commit 446b264

Browse files
committed
primitives - sentry - lastApprovedResponse - make last_approved an Option
1 parent 6fa6fb3 commit 446b264

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

primitives/src/sentry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct ChannelAllResponse {
7070
#[derive(Serialize, Deserialize, Debug)]
7171
#[serde(rename_all = "camelCase")]
7272
pub struct LastApprovedResponse {
73-
pub last_approved: LastApproved,
73+
pub last_approved: Option<LastApproved>,
7474
pub heartbeats: Option<Vec<Heartbeat>>,
7575
}
7676

validator_worker/src/follower.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ async fn on_new_state<'a, A: Adapter + 'static>(
8787
let last_approve_response = await!(iface.get_last_approved())?;
8888
let prev_balances = last_approve_response
8989
.last_approved
90-
.new_state
91-
.map(|new_state| new_state.balances)
92-
.unwrap_or_else(Default::default);
90+
.and_then(|last_approved| last_approved.new_state)
91+
.map_or(Default::default(), |new_state| new_state.balances);
92+
9393
if !is_valid_transition(&iface.channel, &prev_balances, &proposed_balances) {
9494
return Ok(await!(on_error(
9595
&iface,
@@ -134,7 +134,6 @@ async fn on_error<'a, A: Adapter + 'static>(
134134
signature: new_state.signature.clone(),
135135
balances: Some(new_state.balances.clone()),
136136
/// The NewState timestamp that is being rejected
137-
// TODO: Double check this, if we decide to have 2 timestamps - 1 for the RejectState & 1 for NewState timestamp
138137
timestamp: Some(Utc::now()),
139138
})]);
140139

0 commit comments

Comments
 (0)