@@ -2056,9 +2056,8 @@ pub struct GetMasternodePaymentsResult {
20562056#[ derive( Clone , PartialEq , Eq , Debug , Deserialize , Serialize ) ]
20572057#[ serde( rename_all = "camelCase" ) ]
20582058pub struct DMNState {
2059- #[ serde( default ) ]
2060- #[ serde_as( as = "Option<DisplayFromStr>" ) ]
2061- pub service : Option < SocketAddr > ,
2059+ #[ serde_as( as = "DisplayFromStr" ) ]
2060+ pub service : SocketAddr ,
20622061 pub registered_height : u32 ,
20632062 #[ serde( default , rename = "PoSeRevivedHeight" , deserialize_with = "deserialize_u32_opt" ) ]
20642063 pub pose_revived_height : Option < u32 > ,
@@ -2090,7 +2089,7 @@ pub struct DMNState {
20902089#[ derive( Clone , PartialEq , Eq , Debug , Deserialize ) ]
20912090#[ serde( try_from = "DMNStateDiffIntermediate" ) ]
20922091pub struct DMNStateDiff {
2093- pub service : Option < Option < SocketAddr > > ,
2092+ pub service : Option < SocketAddr > ,
20942093 pub registered_height : Option < u32 > ,
20952094 pub last_paid_height : Option < u32 > ,
20962095 pub consecutive_payments : Option < i32 > ,
@@ -2175,7 +2174,7 @@ impl TryFrom<DMNStateDiffIntermediate> for DMNStateDiff {
21752174 . transpose ( ) ?;
21762175
21772176 Ok ( DMNStateDiff {
2178- service : service . map ( Some ) ,
2177+ service,
21792178 registered_height,
21802179 last_paid_height,
21812180 consecutive_payments,
@@ -2317,7 +2316,7 @@ impl DMNState {
23172316 self . pub_key_operator = pub_key_operator;
23182317 }
23192318 if let Some ( service) = service {
2320- self . service = service;
2319+ self . service = service
23212320 }
23222321 if let Some ( revocation_reason) = revocation_reason {
23232322 self . revocation_reason = revocation_reason;
@@ -2367,9 +2366,8 @@ pub enum MasternodeState {
23672366pub struct MasternodeStatus {
23682367 #[ serde( default , deserialize_with = "deserialize_outpoint" ) ]
23692368 pub outpoint : dashcore:: OutPoint ,
2370- #[ serde( default ) ]
2371- #[ serde_as( as = "Option<DisplayFromStr>" ) ]
2372- pub service : Option < SocketAddr > ,
2369+ #[ serde_as( as = "DisplayFromStr" ) ]
2370+ pub service : SocketAddr ,
23732371 #[ serde( rename = "proTxHash" ) ]
23742372 pub pro_tx_hash : ProTxHash ,
23752373 #[ serde( rename = "type" ) ]
@@ -3260,8 +3258,7 @@ mod tests {
32603258 use serde_json:: json;
32613259
32623260 use crate :: {
3263- DMNState , ExtendedQuorumListResult , MasternodeListDiff , MasternodeStatus , MnSyncStatus ,
3264- QuorumType , deserialize_u32_opt,
3261+ ExtendedQuorumListResult , MasternodeListDiff , MnSyncStatus , QuorumType , deserialize_u32_opt,
32653262 } ;
32663263
32673264 #[ test]
@@ -3454,138 +3451,4 @@ mod tests {
34543451
34553452 println ! ( "{:#?}" , result) ;
34563453 }
3457-
3458- /// Core v24 regression: `service` is omitted when `-deprecatedrpc=service` is not set.
3459- #[ test]
3460- fn deserialize_dmn_state_without_service ( ) {
3461- let json = json ! ( {
3462- "registeredHeight" : 850310 ,
3463- "lastPaidHeight" : 0 ,
3464- "consecutivePayments" : 0 ,
3465- "PoSePenalty" : 0 ,
3466- "PoSeRevivedHeight" : -1 ,
3467- "PoSeBanHeight" : -1 ,
3468- "revocationReason" : 0 ,
3469- "ownerAddress" : "yPBWCdMRY5PsS3hJzs7csbdWQVRR85yxUz" ,
3470- "votingAddress" : "ySM11LUD65Bi4p1gm68XLkdWc65TBKRzvQ" ,
3471- "payoutAddress" : "yX4Ve7Q8Y4jscV4LZJD8HVCHKyePzR3MhA" ,
3472- "pubKeyOperator" : "8ed3f0c208efbcfc815cbfb94490dc68cf2e29d44dd9f8a91e20e06057aa110d7062c8ab7ccc85a9ff0c88760157f563"
3473- } ) ;
3474-
3475- let result: DMNState =
3476- serde_json:: from_value ( json) . expect ( "should deserialize DMNState without service" ) ;
3477- assert_eq ! ( result. service, None ) ;
3478- assert_eq ! ( result. registered_height, 850310 ) ;
3479- assert_eq ! ( result. platform_p2p_port, None ) ;
3480- assert_eq ! ( result. platform_http_port, None ) ;
3481- }
3482-
3483- /// Core v24 regression: `service` present should still deserialize correctly.
3484- #[ test]
3485- fn deserialize_dmn_state_with_service ( ) {
3486- let json = json ! ( {
3487- "service" : "194.135.88.228:6667" ,
3488- "registeredHeight" : 850310 ,
3489- "lastPaidHeight" : 0 ,
3490- "consecutivePayments" : 0 ,
3491- "PoSePenalty" : 0 ,
3492- "PoSeRevivedHeight" : -1 ,
3493- "PoSeBanHeight" : -1 ,
3494- "revocationReason" : 0 ,
3495- "ownerAddress" : "yPBWCdMRY5PsS3hJzs7csbdWQVRR85yxUz" ,
3496- "votingAddress" : "ySM11LUD65Bi4p1gm68XLkdWc65TBKRzvQ" ,
3497- "payoutAddress" : "yX4Ve7Q8Y4jscV4LZJD8HVCHKyePzR3MhA" ,
3498- "pubKeyOperator" : "8ed3f0c208efbcfc815cbfb94490dc68cf2e29d44dd9f8a91e20e06057aa110d7062c8ab7ccc85a9ff0c88760157f563"
3499- } ) ;
3500-
3501- let result: DMNState =
3502- serde_json:: from_value ( json) . expect ( "should deserialize DMNState with service" ) ;
3503- assert_eq ! ( result. service, Some ( "194.135.88.228:6667" . parse( ) . unwrap( ) ) ) ;
3504- }
3505-
3506- /// Core v24 regression: `MasternodeStatus` without `service`.
3507- #[ test]
3508- fn deserialize_masternode_status_without_service ( ) {
3509- let json = json ! ( {
3510- "outpoint" : "0000000000000000000000000000000000000000000000000000000000000000-0" ,
3511- "proTxHash" : "c560a9be2be9db79e1aaa16e4dd3cd22bddcb0155f88aba68aa4797d375ef370" ,
3512- "type" : "Regular" ,
3513- "collateralHash" : "ff6226e6c97bfcf40b6d04e12e3f75678024988823bfba28cde2a9ac11b1a765" ,
3514- "collateralIndex" : 1 ,
3515- "dmnState" : {
3516- "registeredHeight" : 850310 ,
3517- "lastPaidHeight" : 0 ,
3518- "consecutivePayments" : 0 ,
3519- "PoSePenalty" : 0 ,
3520- "PoSeRevivedHeight" : -1 ,
3521- "PoSeBanHeight" : -1 ,
3522- "revocationReason" : 0 ,
3523- "ownerAddress" : "yPBWCdMRY5PsS3hJzs7csbdWQVRR85yxUz" ,
3524- "votingAddress" : "ySM11LUD65Bi4p1gm68XLkdWc65TBKRzvQ" ,
3525- "payoutAddress" : "yX4Ve7Q8Y4jscV4LZJD8HVCHKyePzR3MhA" ,
3526- "pubKeyOperator" : "8ed3f0c208efbcfc815cbfb94490dc68cf2e29d44dd9f8a91e20e06057aa110d7062c8ab7ccc85a9ff0c88760157f563"
3527- } ,
3528- "state" : "READY" ,
3529- "status" : "Ready"
3530- } ) ;
3531-
3532- let result: MasternodeStatus = serde_json:: from_value ( json)
3533- . expect ( "should deserialize MasternodeStatus without service" ) ;
3534- assert_eq ! ( result. service, None ) ;
3535- assert_eq ! ( result. dmn_state. service, None ) ;
3536- }
3537-
3538- /// DMNState diff correctly captures clearing of service field.
3539- #[ test]
3540- fn dmn_state_diff_clears_service ( ) {
3541- let with_service = DMNState {
3542- service : Some ( "194.135.88.228:6667" . parse ( ) . unwrap ( ) ) ,
3543- registered_height : 850310 ,
3544- pose_revived_height : None ,
3545- pose_ban_height : None ,
3546- revocation_reason : 0 ,
3547- owner_address : [ 0u8 ; 20 ] ,
3548- voting_address : [ 0u8 ; 20 ] ,
3549- payout_address : [ 0u8 ; 20 ] ,
3550- pub_key_operator : vec ! [ 0u8 ; 48 ] ,
3551- operator_payout_address : None ,
3552- platform_node_id : None ,
3553- platform_p2p_port : None ,
3554- platform_http_port : None ,
3555- } ;
3556- let without_service = DMNState {
3557- service : None ,
3558- ..with_service. clone ( )
3559- } ;
3560-
3561- // Diff from Some → None should capture the change
3562- let diff = with_service
3563- . compare_to_newer_dmn_state ( & without_service)
3564- . expect ( "should detect service removal" ) ;
3565- assert_eq ! ( diff. service, Some ( None ) , "diff should record service cleared" ) ;
3566-
3567- // Applying the diff should clear the service
3568- let mut state = with_service. clone ( ) ;
3569- state. apply_diff ( diff) ;
3570- assert_eq ! ( state. service, None , "service should be None after applying diff" ) ;
3571-
3572- // Diff from None → Some should also work
3573- let diff = without_service
3574- . compare_to_newer_dmn_state ( & with_service)
3575- . expect ( "should detect service addition" ) ;
3576- assert_eq ! (
3577- diff. service,
3578- Some ( Some ( "194.135.88.228:6667" . parse( ) . unwrap( ) ) ) ,
3579- "diff should record service set"
3580- ) ;
3581-
3582- // Applying the diff should restore the service
3583- let mut state = without_service;
3584- state. apply_diff ( diff) ;
3585- assert_eq ! (
3586- state. service,
3587- Some ( "194.135.88.228:6667" . parse( ) . unwrap( ) ) ,
3588- "service should be restored after applying diff"
3589- ) ;
3590- }
35913454}
0 commit comments