@@ -15,7 +15,6 @@ use crate::network::message_qrinfo::{QRInfo, QuorumSnapshot};
1515use crate :: network:: message_sml:: MnListDiff ;
1616use crate :: prelude:: CoreBlockHeight ;
1717use crate :: sml:: error:: SmlError ;
18- use crate :: sml:: error:: SmlError :: CorruptedCodeExecution ;
1918use crate :: sml:: llmq_type:: LLMQType ;
2019use crate :: sml:: masternode_list:: MasternodeList ;
2120use crate :: sml:: masternode_list:: from_diff:: TryIntoWithBlockHashLookup ;
@@ -355,34 +354,41 @@ impl MasternodeListEngine {
355354 Some ( diff_end_height) => diff_end_height,
356355 } ;
357356
358- let mut masternode_list =
359- base_masternode_list. apply_diff ( masternode_list_diff. clone ( ) , diff_end_height) ?;
360-
361357 #[ cfg( feature = "quorum_validation" ) ]
362- if verify_quorums {
363- // We only need to verify new quorums
364- for new_quorum in & masternode_list_diff. new_quorums {
365- let quorum = masternode_list
366- . quorum_entry_of_type_for_quorum_hash_mut (
367- new_quorum. llmq_type ,
368- new_quorum. quorum_hash ,
369- )
370- . ok_or ( CorruptedCodeExecution (
371- "masternode list after diff does not contain new quorum" . to_string ( ) ,
372- ) ) ?;
373- self . validate_and_update_quorum_status ( quorum) ;
358+ {
359+ let mut masternode_list =
360+ base_masternode_list. apply_diff ( masternode_list_diff. clone ( ) , diff_end_height) ?;
361+ if verify_quorums {
362+ // We only need to verify new quorums
363+ for new_quorum in & masternode_list_diff. new_quorums {
364+ let quorum = masternode_list
365+ . quorum_entry_of_type_for_quorum_hash_mut (
366+ new_quorum. llmq_type ,
367+ new_quorum. quorum_hash ,
368+ )
369+ . ok_or ( SmlError :: CorruptedCodeExecution (
370+ "masternode list after diff does not contain new quorum" . to_string ( ) ,
371+ ) ) ?;
372+ self . validate_and_update_quorum_status ( quorum) ;
373+ }
374374 }
375+ self . masternode_lists . insert ( diff_end_height, masternode_list) ;
375376 }
377+
376378 #[ cfg( not( feature = "quorum_validation" ) ) ]
377- if verify_quorums {
378- return Err ( SmlError :: FeatureNotTurnedOn (
379- "quorum validation feature is not turned on" . to_string ( ) ,
380- ) ) ;
379+ {
380+ let masternode_list =
381+ base_masternode_list. apply_diff ( masternode_list_diff. clone ( ) , diff_end_height) ?;
382+ if verify_quorums {
383+ return Err ( SmlError :: FeatureNotTurnedOn (
384+ "quorum validation feature is not turned on" . to_string ( ) ,
385+ ) ) ;
386+ }
387+ self . masternode_lists . insert ( diff_end_height, masternode_list) ;
381388 }
382389
383390 self . block_hashes . insert ( diff_end_height, block_hash) ;
384391 self . block_heights . insert ( block_hash, diff_end_height) ;
385- self . masternode_lists . insert ( diff_end_height, masternode_list) ;
386392
387393 Ok ( ( ) )
388394 }
@@ -441,6 +447,8 @@ impl MasternodeListEngine {
441447#[ cfg( test) ]
442448mod tests {
443449
450+ use bincode:: Decode ;
451+
444452 use crate :: sml:: llmq_entry_verification:: LLMQEntryVerificationStatus ;
445453 use crate :: sml:: llmq_type:: LLMQType ;
446454 use crate :: sml:: llmq_type:: LLMQType :: { Llmqtype50_60 , Llmqtype400_60 , Llmqtype400_85 } ;
0 commit comments