1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::collections::HashSet;

use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};

use crate::{
    identifier::{DigestIdentifier, KeyIdentifier},
    signature::Signature,
};

pub(crate) mod error;
pub(crate) mod inner_manager;
pub(crate) mod manager;

#[derive(Clone, Serialize, Deserialize, Debug, BorshSerialize, BorshDeserialize)]
pub enum DistributionMessagesNew {
    ProvideSignatures(AskForSignatures),
    SignaturesReceived(SignaturesReceived),
    SignaturesNeeded {
        subject_id: DigestIdentifier,
        sn: u64,
    },
}

#[derive(Clone, Serialize, Deserialize, Debug, BorshSerialize, BorshDeserialize)]
pub struct AskForSignatures {
    pub subject_id: DigestIdentifier,
    pub sn: u64,
    pub signatures_requested: HashSet<KeyIdentifier>,
    pub sender_id: KeyIdentifier,
}

#[derive(Clone, Serialize, Deserialize, Debug, BorshSerialize, BorshDeserialize)]
pub struct SignaturesReceived {
    pub subject_id: DigestIdentifier,
    pub sn: u64,
    pub signatures: HashSet<Signature>,
}

// Message Recieved from Ledger
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct StartDistribution {
    subject_id: DigestIdentifier,
    sn: u64,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub enum LedgerMessages {
    LceRequested(LceRequested),
    EventRequested(EventRequested),
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct LceRequested {
    pub subject_id: DigestIdentifier,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct EventRequested {
    pub subject_id: DigestIdentifier,
    pub sn: u64,
}