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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
crate::ix!();

/**
  | Validation result for a single transaction
  | mempool acceptance.
  |
  */
pub struct MempoolAcceptResult {

    pub result_type: MempoolAcceptResultType,
    pub state:       TxValidationState,

    /*
      | The following fields are only present
      | when m_result_type = ResultType::VALID
      |
      */

    /**
      | Mempool transactions replaced by the
      | tx per BIP 125 rules.
      |
      */
    pub replaced_transactions: Option<LinkedList<TransactionRef>>,

    /**
      | Raw base fees in satoshis.
      |
      */
    pub base_fees:             Option<Amount>,
}

/**
  | Used to indicate the results of mempool
  | validation.
  |
  */
#[derive(PartialEq,Eq,Clone,Debug)]
pub enum MempoolAcceptResultType {

    /**
      | Fully validated, valid.
      |
      */
    VALID, 

    /**
      | Invalid.
      |
      */
    INVALID, 
}

impl MempoolAcceptResult {

    
    pub fn failure(state: TxValidationState) -> MempoolAcceptResult {
        
        todo!();
        /*
            return MempoolAcceptResult(state);
        */
    }
    
    pub fn success(
        replaced_txns: LinkedList<TransactionRef>,
        fees:          Amount) -> MempoolAcceptResult {
        
        todo!();
        /*
            return MempoolAcceptResult(std::move(replaced_txns), fees);
        */
    }

    /*
      | Private constructors. Use static methods
      | 
      | MempoolAcceptResult::Success, etc.
      | to construct.
      |
      */

    /**
      | Constructor for failure case
      |
      */
    pub fn new_failure_case(state: TxValidationState) -> Self {
    
        todo!();
        /*
           : m_result_type(ResultType::INVALID), m_state(state) 
           Assume(!state.IsValid()); // Can be invalid or error
           */
    }

    /**
      | Constructor for success case
      |
      */
    pub fn new_success_case(
        replaced_txns: LinkedList<TransactionRef>,
        fees:          Amount) -> Self {
    
        todo!();
        /*
           : m_result_type(ResultType::VALID),
           m_replaced_transactions(std::move(replaced_txns)), m_base_fees(fees)
           */
    }
}

/**
  | Validation result for package mempool
  | acceptance.
  |
  */
pub struct PackageMempoolAcceptResult {

    state:      PackageValidationState,

    /**
      | Map from wtxid to finished MempoolAcceptResults.
      | The client is responsible for keeping
      | track of the transaction objects themselves.
      | If a result is not present, it means validation
      | was unfinished for that transaction.
      | If there was a package-wide error (see
      | result in m_state), m_tx_results will
      | be empty.
      |
      */
    tx_results: HashMap<u256,MempoolAcceptResult>,
}

impl PackageMempoolAcceptResult {
    
    pub fn new_with_state_and_results(
        state:   PackageValidationState,
        results: HashMap<u256,MempoolAcceptResult>) -> Self {
    
        todo!();
        /*
           : m_state{state}, m_tx_results(std::move(results))
        */
    }

    /**
      | Constructor to create a PackageMempoolAcceptResult
      | from a single MempoolAcceptResult
      |
      */
    pub fn new_with_wtxid_and_result(
        wtxid:  &u256,
        result: &MempoolAcceptResult) -> Self {
    
        todo!();
        /*
            : m_tx_results{ {wtxid, result} }
        */
    }
}