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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use super::ledger::Ledger;
use crate::value::Value;

impl Ledger {
    pub fn stats(&self) -> Vec<String> {
        let Ledger {
            utxos,
            oldutxos,
            accounts,
            settings: _,
            updates: _,
            multisig,
            delegation: _,
            static_params: _,
            date: _,
            chain_length: _,
            era: _,
            pots: _,
            leaders_log: _,
            votes: _,
            governance: _,
            token_totals: _,
        } = self;

        let stats = vec![
            format!(
                "utxos   : #{} Total={:?}",
                utxos.iter().count(),
                Value::sum(utxos.iter().map(|x| x.output.value))
            ),
            format!(
                "oldutxos: #{} Total={:?}",
                oldutxos.iter().count(),
                Value::sum(oldutxos.iter().map(|x| x.output.value))
            ),
            format!(
                "accounts: #{} Total={:?}",
                accounts.iter().count(),
                Value::sum(accounts.iter().map(|x| x.1.value))
            ),
            format!(
                "multisig: #{} Total={:?}",
                multisig.iter_accounts().count(),
                Value::sum(multisig.iter_accounts().map(|x| x.1.value))
            ),
        ];

        stats
    }

    pub fn info_eq(&self, other: &Self) -> Vec<String> {
        let Ledger {
            utxos: utxos1,
            oldutxos: oldutxos1,
            accounts: accounts1,
            settings: settings1,
            updates: updates1,
            multisig: multisig1,
            delegation: delegation1,
            static_params: static_params1,
            date: date1,
            chain_length: chain_length1,
            era: era1,
            pots: pots1,
            leaders_log: leaders_log1,
            votes: votes1,
            governance: governance1,
            token_totals: token_totals1,
        } = self;

        let Ledger {
            utxos: utxos2,
            oldutxos: oldutxos2,
            accounts: accounts2,
            settings: settings2,
            updates: updates2,
            multisig: multisig2,
            delegation: delegation2,
            static_params: static_params2,
            date: date2,
            chain_length: chain_length2,
            era: era2,
            pots: pots2,
            leaders_log: leaders_log2,
            votes: votes2,
            governance: governance2,
            token_totals: token_totals2,
        } = other;

        let info = vec![
            format!("utxos-same: {}", utxos1 == utxos2),
            format!("oldutxos-same: {}", oldutxos1 == oldutxos2),
            format!("accounts-same: {}", accounts1 == accounts2),
            format!("multisig-same: {}", multisig1 == multisig2),
            format!("settings-same: {}", settings1 == settings2),
            format!("delegation-same: {}", delegation1 == delegation2),
            format!("static_params-same: {}", static_params1 == static_params2),
            format!("updates-same: {}", updates1 == updates2),
            format!("chain-length: {}", chain_length1 == chain_length2),
            format!("date-same: {}", date1 == date2),
            format!("era-same: {}", era1 == era2),
            format!("pots-same: {}", pots1 == pots2),
            format!("leaders-log-same: {}", leaders_log1 == leaders_log2),
            format!("vote-plans: {}", votes1 == votes2),
            format!("governance: {}", governance1 == governance2),
            format!("token-totals: {}", token_totals1 == token_totals2),
        ];

        info
    }
}