Skip to content

Commit 22fb1de

Browse files
committed
primitives - validator - document messages
1 parent 347ec83 commit 22fb1de

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

primitives/src/validator.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ pub mod messages {
308308
}
309309
}
310310

311+
/// Generated by the follower when a [`NewState`]
312+
/// is generated by the leader and the state is signable and correct.
311313
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
312314
#[serde(rename_all = "camelCase")]
313315
pub struct ApproveState {
@@ -316,6 +318,8 @@ pub mod messages {
316318
pub is_healthy: bool,
317319
}
318320

321+
/// Generated by the [`Channel.leader`](crate::Channel::leader)
322+
/// on changed balances for the [`Channel`](crate::Channel).
319323
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
320324
#[serde(rename_all = "camelCase")]
321325
pub struct NewState<S: BalancesState> {
@@ -335,6 +339,18 @@ pub mod messages {
335339
}
336340
}
337341

342+
/// Generated by the [`Channel.follower`] on:
343+
///
344+
/// - Payout mismatch in the [`NewState`] between earner & spenders (i.e. their sum is not equal)
345+
/// - Invalid [`NewState`] root hash.
346+
/// - Failed verification of the expected signer ([`Channel.leader`])
347+
/// with the proposed [`NewState`] signature and state root.
348+
/// - Invalid state transition (balances should always go up)
349+
/// - [`NewState`] is unsignable because the health is below the [`Config.health_unsignable_promilles`]
350+
///
351+
/// [`Channel.follower`]: crate::Channel::follower
352+
/// [`Channel.leader`]: crate::Channel::leader
353+
/// [`Config.health_unsignable_promilles`]: crate::Config::health_unsignable_promilles
338354
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
339355
#[serde(rename_all = "camelCase")]
340356
pub struct RejectState<S: BalancesState> {
@@ -347,6 +363,13 @@ pub mod messages {
347363
pub timestamp: DateTime<Utc>,
348364
}
349365

366+
/// Heartbeat sent to each [`Channel`] validator by the
367+
/// other validator of the [`Channel`].
368+
///
369+
/// The Heartbeat is sent on regular intervals every [`Config.heartbeat_time`].
370+
///
371+
/// [`Channel`]: crate::Channel
372+
/// [`Config.heartbeat_time`]: crate::Config::heartbeat_time
350373
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
351374
#[serde(rename_all = "camelCase")]
352375
pub struct Heartbeat {
@@ -365,6 +388,7 @@ pub mod messages {
365388
}
366389
}
367390

391+
/// The message types used by validator.
368392
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
369393
#[serde(tag = "type")]
370394
pub enum MessageTypes {

0 commit comments

Comments
 (0)