Skip to content

Commit 6136ae2

Browse files
committed
fix: LastApproved type
1 parent 52f5790 commit 6136ae2

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

primitives/src/sentry.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::validator::{Heartbeat, MessageTypes};
1+
use crate::validator::{ApproveState, Heartbeat, MessageTypes, NewState};
22
use crate::{BigNum, Channel};
33
use chrono::{DateTime, Utc};
44
use serde::{Deserialize, Serialize};
@@ -9,9 +9,23 @@ use std::collections::HashMap;
99
#[serde(rename_all = "camelCase")]
1010
pub struct LastApproved {
1111
/// NewState can be None if the channel is brand new
12-
pub new_state: Option<ValidatorMessage>,
12+
pub new_state: Option<NewStateValidatorMessage>,
1313
/// ApproveState can be None if the channel is brand new
14-
pub approved_state: Option<ValidatorMessage>,
14+
pub approved_state: Option<ApproveStateValidatorMessage>,
15+
}
16+
17+
#[derive(Serialize, Deserialize, Debug)]
18+
pub struct NewStateValidatorMessage {
19+
pub from: String,
20+
pub received: DateTime<Utc>,
21+
pub msg: NewState,
22+
}
23+
24+
#[derive(Serialize, Deserialize, Debug)]
25+
pub struct ApproveStateValidatorMessage {
26+
pub from: String,
27+
pub received: DateTime<Utc>,
28+
pub msg: ApproveState,
1529
}
1630

1731
#[serde(tag = "type", rename_all = "SCREAMING_SNAKE_CASE")]

validator_worker/src/follower.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ async fn on_new_state<'a, A: Adapter + 'static>(
8080
let prev_balances = last_approve_response
8181
.last_approved
8282
.and_then(|last_approved| last_approved.new_state)
83-
.map_or(Default::default(), |new_state| match new_state.msg {
84-
MessageTypes::NewState(state) => state.balances,
85-
_ => Default::default(),
86-
});
83+
.map_or(Default::default(), |new_state| new_state.msg.balances);
8784

8885
if !is_valid_transition(&iface.channel, &prev_balances, &proposed_balances) {
8986
drop(adapter);

0 commit comments

Comments
 (0)