Skip to content

Commit 6fa6fb3

Browse files
committed
validator_worker - follower - fix prev_balances, since LastApprove.new_state is an option
1 parent 7d8800e commit 6fa6fb3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

validator_worker/src/follower.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ async fn on_new_state<'a, A: Adapter + 'static>(
8585
}
8686

8787
let last_approve_response = await!(iface.get_last_approved())?;
88-
// TODO: Check if it's possible to have an empty response (i.e. we don't have LastApprove)
89-
let prev_balances = last_approve_response.last_approved.new_state.balances;
88+
let prev_balances = last_approve_response
89+
.last_approved
90+
.new_state
91+
.map(|new_state| new_state.balances)
92+
.unwrap_or_else(Default::default);
9093
if !is_valid_transition(&iface.channel, &prev_balances, &proposed_balances) {
9194
return Ok(await!(on_error(
9295
&iface,

0 commit comments

Comments
 (0)