@@ -52,25 +52,25 @@ use crate::{Address, Network, OutPoint, ScriptBuf, VarInt, io};
5252#[ cfg_attr( feature = "bincode" , derive( Encode , Decode ) ) ]
5353#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5454#[ cfg_attr( feature = "serde" , serde( crate = "actual_serde" ) ) ]
55- pub enum MasternodeType {
55+ pub enum ProviderMasternodeType {
5656 Regular = 0 ,
5757 HighPerformance = 1 ,
5858}
5959
60- impl Encodable for MasternodeType {
60+ impl Encodable for ProviderMasternodeType {
6161 fn consensus_encode < W : io:: Write + ?Sized > ( & self , mut w : & mut W ) -> Result < usize , io:: Error > {
6262 let variant = self ;
6363 let len = ( * variant as u16 ) . consensus_encode ( & mut w) ?;
6464 Ok ( len)
6565 }
6666}
6767
68- impl Decodable for MasternodeType {
68+ impl Decodable for ProviderMasternodeType {
6969 fn consensus_decode < R : io:: Read + ?Sized > ( r : & mut R ) -> Result < Self , encode:: Error > {
7070 let variant = u16:: consensus_decode ( r) ?;
7171 match variant {
72- 0 => Ok ( MasternodeType :: Regular ) ,
73- 1 => Ok ( MasternodeType :: HighPerformance ) ,
72+ 0 => Ok ( ProviderMasternodeType :: Regular ) ,
73+ 1 => Ok ( ProviderMasternodeType :: HighPerformance ) ,
7474 received => Err ( encode:: Error :: InvalidEnumValue {
7575 max : 1 ,
7676 received,
@@ -98,8 +98,8 @@ impl Decodable for MasternodeType {
9898#[ cfg_attr( feature = "serde" , serde( crate = "actual_serde" ) ) ]
9999pub struct ProviderRegistrationPayload {
100100 pub version : u16 ,
101- pub provider_type : MasternodeType ,
102- pub provider_mode : u16 ,
101+ pub masternode_type : ProviderMasternodeType ,
102+ pub masternode_mode : u16 ,
103103 pub collateral_outpoint : OutPoint ,
104104 pub service_address : SocketAddr ,
105105 pub owner_key_hash : PubkeyHash ,
@@ -108,7 +108,7 @@ pub struct ProviderRegistrationPayload {
108108 pub operator_reward : u16 ,
109109 pub script_payout : ScriptBuf ,
110110 pub inputs_hash : InputsHash ,
111- pub payload_sig : Vec < u8 > ,
111+ pub signature : Vec < u8 > ,
112112 pub platform_node_id : Option < PubkeyHash > ,
113113 pub platform_p2p_port : Option < u16 > ,
114114 pub platform_http_port : Option < u16 > ,
@@ -158,9 +158,9 @@ impl ProviderRegistrationPayload {
158158 pub fn size ( & self ) -> usize {
159159 let mut size = 2 + 2 + 2 + 32 + 4 + 16 + 2 + 20 + 48 + 20 + 2 + 32 ; // 182 bytes
160160 let script_payout_len = self . script_payout . 0 . len ( ) ;
161- let payload_sig_len = self . payload_sig . len ( ) ;
161+ let signature_len = self . signature . len ( ) ;
162162 size += VarInt ( script_payout_len as u64 ) . len ( ) + script_payout_len;
163- size += VarInt ( payload_sig_len as u64 ) . len ( ) + payload_sig_len ;
163+ size += VarInt ( signature_len as u64 ) . len ( ) + signature_len ;
164164 size
165165 }
166166}
@@ -170,8 +170,8 @@ impl SpecialTransactionBasePayloadEncodable for ProviderRegistrationPayload {
170170 let mut len = 0 ;
171171
172172 len += self . version . consensus_encode ( & mut s) ?;
173- len += self . provider_type . consensus_encode ( & mut s) ?;
174- len += self . provider_mode . consensus_encode ( & mut s) ?;
173+ len += self . masternode_type . consensus_encode ( & mut s) ?;
174+ len += self . masternode_mode . consensus_encode ( & mut s) ?;
175175 len += self . collateral_outpoint . consensus_encode ( & mut s) ?;
176176 len += self . service_address . consensus_encode ( & mut s) ?;
177177 len += self . owner_key_hash . consensus_encode ( & mut s) ?;
@@ -181,10 +181,10 @@ impl SpecialTransactionBasePayloadEncodable for ProviderRegistrationPayload {
181181 len += self . script_payout . consensus_encode ( & mut s) ?;
182182 len += self . inputs_hash . consensus_encode ( & mut s) ?;
183183
184- if self . version >= 2 && self . provider_type == MasternodeType :: HighPerformance {
184+ if self . version >= 2 && self . masternode_type == ProviderMasternodeType :: HighPerformance {
185185 len += self
186186 . platform_node_id
187- . unwrap_or_else ( || PubkeyHash :: all_zeros ( ) )
187+ . unwrap_or_else ( PubkeyHash :: all_zeros)
188188 . consensus_encode ( & mut s) ?;
189189 len += self . platform_p2p_port . unwrap_or_default ( ) . consensus_encode ( & mut s) ?;
190190 len += self . platform_http_port . unwrap_or_default ( ) . consensus_encode ( & mut s) ?;
@@ -204,15 +204,15 @@ impl Encodable for ProviderRegistrationPayload {
204204 fn consensus_encode < W : io:: Write + ?Sized > ( & self , mut w : & mut W ) -> Result < usize , io:: Error > {
205205 let mut len = 0 ;
206206 len += self . base_payload_data_encode ( & mut w) ?;
207- len += self . payload_sig . consensus_encode ( & mut w) ?;
207+ len += self . signature . consensus_encode ( & mut w) ?;
208208 Ok ( len)
209209 }
210210}
211211
212212impl Decodable for ProviderRegistrationPayload {
213213 fn consensus_decode < R : io:: Read + ?Sized > ( r : & mut R ) -> Result < Self , encode:: Error > {
214214 let version = u16:: consensus_decode ( r) ?;
215- let provider_type = MasternodeType :: consensus_decode ( r) ?;
215+ let provider_type = ProviderMasternodeType :: consensus_decode ( r) ?;
216216 let provider_mode = u16:: consensus_decode ( r) ?;
217217 let collateral_outpoint = OutPoint :: consensus_decode ( r) ?;
218218 let service_address = SocketAddr :: consensus_decode ( r) ?;
@@ -227,7 +227,7 @@ impl Decodable for ProviderRegistrationPayload {
227227 let mut platform_p2p_port = None ;
228228 let mut platform_http_port = None ;
229229
230- if version >= 2 && provider_type == MasternodeType :: HighPerformance {
230+ if version >= 2 && provider_type == ProviderMasternodeType :: HighPerformance {
231231 platform_node_id = Some ( PubkeyHash :: consensus_decode ( r) ?) ;
232232 platform_p2p_port = Some ( u16:: consensus_decode ( r) ?) ;
233233 platform_http_port = Some ( u16:: consensus_decode ( r) ?) ;
@@ -237,8 +237,8 @@ impl Decodable for ProviderRegistrationPayload {
237237
238238 Ok ( ProviderRegistrationPayload {
239239 version,
240- provider_type,
241- provider_mode,
240+ masternode_type : provider_type,
241+ masternode_mode : provider_mode,
242242 collateral_outpoint,
243243 service_address,
244244 owner_key_hash,
@@ -247,7 +247,7 @@ impl Decodable for ProviderRegistrationPayload {
247247 operator_reward,
248248 script_payout,
249249 inputs_hash,
250- payload_sig,
250+ signature : payload_sig,
251251 platform_node_id,
252252 platform_p2p_port,
253253 platform_http_port,
@@ -266,7 +266,7 @@ mod tests {
266266 use crate :: hash_types:: InputsHash ;
267267 use crate :: internal_macros:: hex;
268268 use crate :: transaction:: special_transaction:: provider_registration:: {
269- MasternodeType , ProviderRegistrationPayload ,
269+ ProviderMasternodeType , ProviderRegistrationPayload ,
270270 } ;
271271 use crate :: { OutPoint , PubkeyHash , ScriptBuf , Transaction , Txid } ;
272272
@@ -333,9 +333,9 @@ mod tests {
333333 provider_registration_payload_version
334334 ) ;
335335 let provider_type = 0 ;
336- assert_eq ! ( expected_provider_registration_payload. provider_type , provider_type) ;
336+ assert_eq ! ( expected_provider_registration_payload. masternode_type , provider_type) ;
337337 let provider_mode = 0 ;
338- assert_eq ! ( expected_provider_registration_payload. provider_mode , provider_mode) ;
338+ assert_eq ! ( expected_provider_registration_payload. masternode_mode , provider_mode) ;
339339
340340 let collateral_outpoint = OutPoint { txid : collateral_hash, vout : collateral_index } ;
341341 assert_eq ! (
@@ -420,7 +420,7 @@ mod tests {
420420 "message digest signatures don't match"
421421 ) ;
422422
423- assert_eq ! ( expected_provider_registration_payload. payload_sig , signature. to_vec( ) ) ;
423+ assert_eq ! ( expected_provider_registration_payload. signature , signature. to_vec( ) ) ;
424424
425425 assert_eq ! ( expected_transaction. txid( ) , tx_id) ;
426426
@@ -440,8 +440,8 @@ mod tests {
440440 special_transaction_payload : Some ( ProviderRegistrationPayloadType (
441441 ProviderRegistrationPayload {
442442 version : provider_registration_payload_version,
443- provider_type,
444- provider_mode,
443+ masternode_type : provider_type,
444+ masternode_mode : provider_mode,
445445 collateral_outpoint,
446446 service_address,
447447 owner_key_hash : PubkeyHash :: from_hex ( owner_key_hash_hex) . unwrap ( ) ,
@@ -450,7 +450,7 @@ mod tests {
450450 operator_reward,
451451 script_payout,
452452 inputs_hash : InputsHash :: from_hex ( inputs_hash_hex) . unwrap ( ) ,
453- payload_sig : signature. to_vec ( ) ,
453+ signature : signature. to_vec ( ) ,
454454 platform_node_id : None ,
455455 platform_p2p_port : None ,
456456 platform_http_port : None ,
@@ -515,9 +515,9 @@ mod tests {
515515 provider_registration_payload_version
516516 ) ;
517517 let provider_type = 0 ;
518- assert_eq ! ( expected_provider_registration_payload. provider_type , provider_type) ;
518+ assert_eq ! ( expected_provider_registration_payload. masternode_type , provider_type) ;
519519 let provider_mode = 0 ;
520- assert_eq ! ( expected_provider_registration_payload. provider_mode , provider_mode) ;
520+ assert_eq ! ( expected_provider_registration_payload. masternode_mode , provider_mode) ;
521521
522522 let collateral_outpoint = OutPoint { txid : collateral_hash, vout : 0 } ;
523523 assert_eq ! (
@@ -604,7 +604,7 @@ mod tests {
604604 "message digest signatures don't match"
605605 ) ;
606606
607- assert_eq ! ( expected_provider_registration_payload. payload_sig , signature. to_vec( ) ) ;
607+ assert_eq ! ( expected_provider_registration_payload. signature , signature. to_vec( ) ) ;
608608
609609 assert_eq ! ( expected_transaction. txid( ) , tx_id) ;
610610
@@ -624,8 +624,8 @@ mod tests {
624624 special_transaction_payload : Some ( ProviderRegistrationPayloadType (
625625 ProviderRegistrationPayload {
626626 version : provider_registration_payload_version,
627- provider_type,
628- provider_mode,
627+ masternode_type : provider_type,
628+ masternode_mode : provider_mode,
629629 collateral_outpoint,
630630 service_address,
631631 owner_key_hash : PubkeyHash :: from_hex ( owner_key_hash_hex) . unwrap ( ) ,
@@ -634,7 +634,7 @@ mod tests {
634634 operator_reward,
635635 script_payout,
636636 inputs_hash : InputsHash :: from_hex ( inputs_hash_hex) . unwrap ( ) ,
637- payload_sig : signature. to_vec ( ) ,
637+ signature : signature. to_vec ( ) ,
638638 platform_node_id : None ,
639639 platform_p2p_port : None ,
640640 platform_http_port : None ,
@@ -658,8 +658,8 @@ mod tests {
658658 let want = 290 ;
659659 let payload = ProviderRegistrationPayload {
660660 version : 0 ,
661- provider_type : MasternodeType :: Regular ,
662- provider_mode : 0 ,
661+ masternode_type : ProviderMasternodeType :: Regular ,
662+ masternode_mode : 0 ,
663663 collateral_outpoint : OutPoint { txid : Txid :: all_zeros ( ) , vout : 0 } ,
664664 service_address : SocketAddr :: V4 ( SocketAddrV4 :: new ( Ipv4Addr :: from_bits ( 0 ) , 0 ) ) ,
665665 owner_key_hash : PubkeyHash :: all_zeros ( ) ,
@@ -668,7 +668,7 @@ mod tests {
668668 operator_reward : 0 ,
669669 script_payout : ScriptBuf :: from_hex ( "00000000000000000000" ) . unwrap ( ) , // 10 bytes
670670 inputs_hash : InputsHash :: all_zeros ( ) ,
671- payload_sig : vec ! [ 0 ; 96 ] ,
671+ signature : vec ! [ 0 ; 96 ] ,
672672 platform_node_id : None ,
673673 platform_p2p_port : None ,
674674 platform_http_port : None ,
0 commit comments