@@ -4,6 +4,7 @@ use std::io::{Read, Write};
44use blsful:: { Bls12381G2Impl , PublicKey } ;
55use crate :: internal_macros:: impl_consensus_encoding;
66use crate :: { ProTxHash , PubkeyHash } ;
7+ use crate :: bls_sig_utils:: BLSPublicKey ;
78use crate :: consensus:: { Decodable , Encodable } ;
89use crate :: consensus:: encode:: Error ;
910use crate :: hash_types:: { ConfirmedHash , Sha256dHash } ;
@@ -41,7 +42,7 @@ impl Encodable for MasternodeType {
4142impl Decodable for MasternodeType {
4243 fn consensus_decode < R : Read + ?Sized > ( reader : & mut R ) -> Result < Self , Error > {
4344 // First decode the variant tag.
44- let variant: u8 = Decodable :: consensus_decode ( reader) ?;
45+ let variant: u16 = Decodable :: consensus_decode ( reader) ?;
4546 match variant {
4647 0 => Ok ( MasternodeType :: Regular ) ,
4748 1 => {
@@ -71,16 +72,58 @@ impl_consensus_encoding!(OperatorPublicKey, data, version);
7172
7273#[ derive( Clone , Eq , PartialEq , Debug ) ]
7374pub struct MasternodeListEntry {
75+ pub version : u16 ,
7476 pub pro_reg_tx_hash : ProTxHash ,
7577 pub confirmed_hash : ConfirmedHash ,
7678 pub service_address : ServiceAddress ,
77- pub operator_public_key : OperatorPublicKey ,
79+ pub operator_public_key : BLSPublicKey ,
7880 pub key_id_voting : PubkeyHash ,
7981 pub is_valid : bool ,
8082 pub mn_type : MasternodeType ,
8183}
8284
83- impl_consensus_encoding ! ( MasternodeListEntry , pro_reg_tx_hash, confirmed_hash, service_address, operator_public_key, key_id_voting, is_valid, mn_type) ;
85+ impl Encodable for MasternodeListEntry {
86+ fn consensus_encode < W : Write + ?Sized > ( & self , writer : & mut W ) -> Result < usize , std:: io:: Error > {
87+ let mut len = 0 ;
88+ len += self . version . consensus_encode ( writer) ?;
89+ len += self . pro_reg_tx_hash . consensus_encode ( writer) ?;
90+ len += self . confirmed_hash . consensus_encode ( writer) ?;
91+ len += self . service_address . consensus_encode ( writer) ?;
92+ len += self . operator_public_key . consensus_encode ( writer) ?;
93+ len += self . key_id_voting . consensus_encode ( writer) ?;
94+ len += self . is_valid . consensus_encode ( writer) ?;
95+ len += self . mn_type . consensus_encode ( writer) ?;
96+ Ok ( len)
97+ }
98+ }
99+
100+ impl Decodable for MasternodeListEntry {
101+ fn consensus_decode < R : Read + ?Sized > ( reader : & mut R ) -> Result < Self , Error > {
102+ let version: u16 = Decodable :: consensus_decode ( reader) ?;
103+ let pro_reg_tx_hash: ProTxHash = Decodable :: consensus_decode ( reader) ?;
104+ let confirmed_hash: ConfirmedHash = Decodable :: consensus_decode ( reader) ?;
105+ let service_address: ServiceAddress = Decodable :: consensus_decode ( reader) ?;
106+ let operator_public_key: BLSPublicKey = Decodable :: consensus_decode ( reader) ?;
107+ let key_id_voting: PubkeyHash = Decodable :: consensus_decode ( reader) ?;
108+ let is_valid: bool = Decodable :: consensus_decode ( reader) ?;
109+ let mn_type: MasternodeType = if version >= 2 {
110+ Decodable :: consensus_decode ( reader) ?
111+ } else {
112+ MasternodeType :: Regular
113+ } ;
114+
115+ Ok ( MasternodeListEntry {
116+ version,
117+ pro_reg_tx_hash,
118+ confirmed_hash,
119+ service_address,
120+ operator_public_key,
121+ key_id_voting,
122+ is_valid,
123+ mn_type,
124+ } )
125+ }
126+ }
84127#[ cfg( feature = "bls" ) ]
85128#[ derive( Clone , Eq , PartialEq ) ]
86129pub struct MasternodeListEntryInfo {
0 commit comments