@@ -18,25 +18,21 @@ use super::*;
1818#[ derive( Clone , Debug , PartialEq , Eq ) ]
1919pub struct PrimaryPing < N : Network > {
2020 pub version : u32 ,
21- pub block_locators : BlockLocators < N > ,
21+ pub current_block_height : u32 ,
2222 pub primary_certificate : Data < BatchCertificate < N > > ,
2323}
2424
2525impl < N : Network > PrimaryPing < N > {
2626 /// Initializes a new ping event.
27- pub const fn new (
28- version : u32 ,
29- block_locators : BlockLocators < N > ,
30- primary_certificate : Data < BatchCertificate < N > > ,
31- ) -> Self {
32- Self { version, block_locators, primary_certificate }
27+ pub const fn new ( version : u32 , current_block_height : u32 , primary_certificate : Data < BatchCertificate < N > > ) -> Self {
28+ Self { version, current_block_height, primary_certificate }
3329 }
3430}
3531
36- impl < N : Network > From < ( u32 , BlockLocators < N > , BatchCertificate < N > ) > for PrimaryPing < N > {
32+ impl < N : Network > From < ( u32 , u32 , BatchCertificate < N > ) > for PrimaryPing < N > {
3733 /// Initializes a new ping event.
38- fn from ( ( version, block_locators , primary_certificate) : ( u32 , BlockLocators < N > , BatchCertificate < N > ) ) -> Self {
39- Self :: new ( version, block_locators , Data :: Object ( primary_certificate) )
34+ fn from ( ( version, current_block_height , primary_certificate) : ( u32 , u32 , BatchCertificate < N > ) ) -> Self {
35+ Self :: new ( version, current_block_height , Data :: Object ( primary_certificate) )
4036 }
4137}
4238
@@ -50,11 +46,8 @@ impl<N: Network> EventTrait for PrimaryPing<N> {
5046
5147impl < N : Network > ToBytes for PrimaryPing < N > {
5248 fn write_le < W : Write > ( & self , mut writer : W ) -> IoResult < ( ) > {
53- // Write the version.
5449 self . version . write_le ( & mut writer) ?;
55- // Write the block locators.
56- self . block_locators . write_le ( & mut writer) ?;
57- // Write the primary certificate.
50+ self . current_block_height . write_le ( & mut writer) ?;
5851 self . primary_certificate . write_le ( & mut writer) ?;
5952
6053 Ok ( ( ) )
@@ -66,19 +59,18 @@ impl<N: Network> FromBytes for PrimaryPing<N> {
6659 // Read the version.
6760 let version = u32:: read_le ( & mut reader) ?;
6861 // Read the block locators.
69- let block_locators = BlockLocators :: read_le ( & mut reader) ?;
62+ let current_block_height = u32 :: read_le ( & mut reader) ?;
7063 // Read the primary certificate.
7164 let primary_certificate = Data :: read_le ( & mut reader) ?;
7265
7366 // Return the ping event.
74- Ok ( Self :: new ( version, block_locators , primary_certificate) )
67+ Ok ( Self :: new ( version, current_block_height , primary_certificate) )
7568 }
7669}
7770
7871#[ cfg( test) ]
7972pub mod prop_tests {
8073 use crate :: { PrimaryPing , certificate_response:: prop_tests:: any_batch_certificate} ;
81- use snarkos_node_sync_locators:: { BlockLocators , test_helpers:: sample_block_locators} ;
8274 use snarkvm:: utilities:: { FromBytes , ToBytes } ;
8375
8476 use bytes:: { Buf , BufMut , BytesMut } ;
@@ -87,14 +79,10 @@ pub mod prop_tests {
8779
8880 type CurrentNetwork = snarkvm:: prelude:: MainnetV0 ;
8981
90- pub fn any_block_locators ( ) -> BoxedStrategy < BlockLocators < CurrentNetwork > > {
91- any :: < u32 > ( ) . prop_map ( sample_block_locators) . boxed ( )
92- }
93-
9482 pub fn any_primary_ping ( ) -> BoxedStrategy < PrimaryPing < CurrentNetwork > > {
95- ( any :: < u32 > ( ) , any_block_locators ( ) , any_batch_certificate ( ) )
96- . prop_map ( |( version, block_locators , batch_certificate) | {
97- PrimaryPing :: from ( ( version, block_locators , batch_certificate. clone ( ) ) )
83+ ( any :: < u32 > ( ) , any :: < u32 > ( ) , any_batch_certificate ( ) )
84+ . prop_map ( |( version, current_block_height , batch_certificate) | {
85+ PrimaryPing :: from ( ( version, current_block_height , batch_certificate. clone ( ) ) )
9886 } )
9987 . boxed ( )
10088 }
@@ -105,7 +93,7 @@ pub mod prop_tests {
10593 primary_ping. write_le ( & mut bytes) . unwrap ( ) ;
10694 let decoded = PrimaryPing :: < CurrentNetwork > :: read_le ( & mut bytes. into_inner ( ) . reader ( ) ) . unwrap ( ) ;
10795 assert_eq ! ( primary_ping. version, decoded. version) ;
108- assert_eq ! ( primary_ping. block_locators , decoded. block_locators ) ;
96+ assert_eq ! ( primary_ping. current_block_height , decoded. current_block_height ) ;
10997 assert_eq ! (
11098 primary_ping. primary_certificate. deserialize_blocking( ) . unwrap( ) ,
11199 decoded. primary_certificate. deserialize_blocking( ) . unwrap( ) ,
0 commit comments