@@ -10,6 +10,7 @@ use crate::error::{Result, SpvError};
1010use crate :: network:: NetworkManager ;
1111use crate :: storage:: StorageManager ;
1212use crate :: types:: AddressBalance ;
13+ use dashcore:: sml:: llmq_entry_verification:: LLMQEntryVerificationStatus ;
1314use dashcore:: sml:: llmq_type:: LLMQType ;
1415use dashcore:: sml:: masternode_list:: MasternodeList ;
1516use dashcore:: sml:: masternode_list_engine:: MasternodeListEngine ;
@@ -84,47 +85,70 @@ impl<
8485 // We have the masternode list, now look for the quorum
8586 match ml. quorums . get ( & quorum_type) {
8687 Some ( quorums) => match quorums. get ( & quorum_hash) {
87- Some ( quorum) => {
88- tracing:: debug!(
89- "Found quorum type {} at height {} with hash {}" ,
88+ // Found the quorum, now check its verification status
89+ Some ( q) => match & q. verified {
90+ // TODO only return verified once validation is reliable
91+ LLMQEntryVerificationStatus :: Verified => {
92+ tracing:: debug!(
93+ "Found verified quorum type {} at height {} with hash {}" ,
94+ quorum_type,
95+ height,
96+ hex:: encode( quorum_hash)
97+ ) ;
98+ Ok ( q. clone ( ) )
99+ }
100+ LLMQEntryVerificationStatus :: Unknown
101+ | LLMQEntryVerificationStatus :: Skipped ( _) => {
102+ tracing:: warn!(
103+ "Quorum type {} at height {} with hash {} found but not yet verified (status: {:?})" ,
90104 quorum_type,
91105 height,
92- hex:: encode( quorum_hash)
106+ hex:: encode( quorum_hash) ,
107+ q. verified
93108 ) ;
94- Ok ( quorum. clone ( ) )
95- }
109+ Ok ( q. clone ( ) )
110+ }
111+ LLMQEntryVerificationStatus :: Invalid ( err) => {
112+ let message = format ! (
113+ "Quorum found but invalid: type {} at height {} with hash {} (reason: {:?})" ,
114+ quorum_type,
115+ height,
116+ hex:: encode( quorum_hash) ,
117+ err
118+ ) ;
119+ tracing:: warn!( message) ;
120+ Err ( SpvError :: QuorumLookupError ( message) )
121+ }
122+ } ,
96123 None => {
97124 let message = format ! ( "Quorum not found: type {} at height {} with hash {} (masternode list exists with {} quorums of this type)" ,
98- quorum_type,
99- height,
100- hex:: encode( quorum_hash) ,
101- quorums. len( ) ) ;
125+ quorum_type,
126+ height,
127+ hex:: encode( quorum_hash) ,
128+ quorums. len( ) ) ;
102129 tracing:: warn!( message) ;
103130 Err ( SpvError :: QuorumLookupError ( message) )
104131 }
105132 } ,
106133 None => {
107- tracing :: warn !(
134+ let message = format ! (
108135 "No quorums of type {} found at height {} (masternode list exists)" ,
109- quorum_type,
110- height
111- ) ;
112- Err ( SpvError :: QuorumLookupError ( format ! (
113- "No quorums of type {} found at height {}" ,
114136 quorum_type, height
115- ) ) )
137+ ) ;
138+ tracing:: warn!( message) ;
139+ Err ( SpvError :: QuorumLookupError ( message) )
116140 }
117141 }
118142 }
119143 None => {
120- tracing:: warn!(
121- "No masternode list found at height {} - cannot retrieve quorum" ,
122- height
144+ let message = format ! (
145+ "Masternode list not found at height {} when looking for quorum type {} with hash {}" ,
146+ height,
147+ quorum_type,
148+ hex:: encode( quorum_hash)
123149 ) ;
124- Err ( SpvError :: QuorumLookupError ( format ! (
125- "No masternode list found at height {}" ,
126- height
127- ) ) )
150+ tracing:: warn!( message) ;
151+ Err ( SpvError :: QuorumLookupError ( message) )
128152 }
129153 }
130154 }
0 commit comments