@@ -13,7 +13,7 @@ use std::sync::Arc;
1313use tracing:: log;
1414
1515// Node considered synced if the head is within this threshold.
16- const SYNCED_EPOCH_THRESHOLD : u64 = 5 ;
16+ const SYNCED_EPOCH_THRESHOLD : u64 = 10 ;
1717
1818/// Represents the overall synchronization status of the Forest node.
1919#[ derive(
@@ -41,10 +41,10 @@ pub enum NodeSyncStatus {
4141 #[ strum( to_string = "Synced" ) ]
4242 Synced ,
4343 /// An error occurred during the sync process.
44- #[ strum( to_string = "error " ) ]
44+ #[ strum( to_string = "Error " ) ]
4545 Error ,
4646 /// Node is configured to not sync (offline mode).
47- #[ strum( to_string = "offline " ) ]
47+ #[ strum( to_string = "Offline " ) ]
4848 Offline ,
4949}
5050
@@ -74,7 +74,7 @@ pub enum ForkSyncStage {
7474 #[ strum( to_string = "Stalled" ) ]
7575 Stalled ,
7676 /// An error occurred processing this specific fork.
77- #[ strum( to_string = "error " ) ]
77+ #[ strum( to_string = "Error " ) ]
7878 Error ,
7979}
8080
@@ -105,24 +105,24 @@ pub struct ForkSyncInfo {
105105#[ derive( Serialize , Deserialize , Debug , Clone , Default , PartialEq , JsonSchema ) ]
106106pub struct SyncStatusReport {
107107 /// Overall status of the node's synchronization.
108- status : NodeSyncStatus ,
108+ pub ( crate ) status : NodeSyncStatus ,
109109 /// The epoch of the heaviest validated tipset on the node's main chain.
110- current_head_epoch : ChainEpoch ,
110+ pub ( crate ) current_head_epoch : ChainEpoch ,
111111 /// The tipset key of the current heaviest validated tipset.
112112 #[ schemars( with = "crate::lotus_json::LotusJson<TipsetKey>" ) ]
113113 #[ serde( with = "crate::lotus_json" ) ]
114- current_head_key : Option < TipsetKey > ,
114+ pub ( crate ) current_head_key : Option < TipsetKey > ,
115115 // Current highest epoch on the network.
116- network_head_epoch : ChainEpoch ,
116+ pub ( crate ) network_head_epoch : ChainEpoch ,
117117 /// Estimated number of epochs the node is behind the network head.
118118 /// Can be negative if the node is slightly ahead, due to estimation variance.
119- epochs_behind : i64 ,
119+ pub ( crate ) epochs_behind : i64 ,
120120 /// List of active fork synchronization tasks the node is currently handling.
121- active_forks : Vec < ForkSyncInfo > ,
121+ pub ( crate ) active_forks : Vec < ForkSyncInfo > ,
122122 /// When the node process started.
123- node_start_time : DateTime < Utc > ,
123+ pub ( crate ) node_start_time : DateTime < Utc > ,
124124 /// Last time this status report was generated.
125- last_updated : DateTime < Utc > ,
125+ pub ( crate ) last_updated : DateTime < Utc > ,
126126}
127127
128128lotus_json_with_self ! ( SyncStatusReport ) ;
@@ -135,58 +135,6 @@ impl SyncStatusReport {
135135 }
136136 }
137137
138- pub ( crate ) fn set_current_chain_head_key ( & mut self , tipset_key : TipsetKey ) {
139- self . current_head_key = Some ( tipset_key) ;
140- }
141-
142- pub ( crate ) fn set_current_chain_head_epoch ( & mut self , epoch : ChainEpoch ) {
143- self . current_head_epoch = epoch;
144- }
145-
146- pub ( crate ) fn get_current_chain_head_epoch ( & self ) -> ChainEpoch {
147- self . current_head_epoch
148- }
149-
150- pub ( crate ) fn set_network_head ( & mut self , epoch : ChainEpoch ) {
151- self . network_head_epoch = epoch;
152- }
153-
154- pub ( crate ) fn get_network_head_epoch ( & self ) -> ChainEpoch {
155- self . network_head_epoch
156- }
157-
158- pub ( crate ) fn get_current_chain_head_key ( & self ) -> Option < & TipsetKey > {
159- self . current_head_key . as_ref ( )
160- }
161-
162- pub ( crate ) fn set_epochs_behind ( & mut self , epochs_behind : i64 ) {
163- self . epochs_behind = epochs_behind;
164- }
165-
166- pub ( crate ) fn get_epochs_behind ( & self ) -> i64 {
167- self . epochs_behind
168- }
169-
170- pub ( crate ) fn set_status ( & mut self , status : NodeSyncStatus ) {
171- self . status = status;
172- }
173-
174- pub ( crate ) fn get_status ( & self ) -> NodeSyncStatus {
175- self . status
176- }
177-
178- pub ( crate ) fn update_active_forks ( & mut self , active_forks : Vec < ForkSyncInfo > ) {
179- self . active_forks = active_forks;
180- }
181-
182- pub ( crate ) fn get_active_forks ( & self ) -> & Vec < ForkSyncInfo > {
183- & self . active_forks
184- }
185-
186- pub fn get_last_updated ( & self ) -> & DateTime < Utc > {
187- & self . last_updated
188- }
189-
190138 pub ( crate ) fn update < DB : Blockstore + Sync + Send + ' static > (
191139 & mut self ,
192140 state_manager : & Arc < StateManager < DB > > ,
@@ -195,8 +143,8 @@ impl SyncStatusReport {
195143 ) {
196144 let heaviest = state_manager. chain_store ( ) . heaviest_tipset ( ) ;
197145 let current_chain_head_epoch = heaviest. epoch ( ) ;
198- self . set_current_chain_head_key ( heaviest. key ( ) . clone ( ) ) ;
199- self . set_current_chain_head_epoch ( current_chain_head_epoch) ;
146+ self . current_head_key = Some ( heaviest. key ( ) . clone ( ) ) ;
147+ self . current_head_epoch = current_chain_head_epoch;
200148
201149 let now = Utc :: now ( ) ;
202150 let now_ts = now. timestamp ( ) as u64 ;
@@ -207,13 +155,13 @@ impl SyncStatusReport {
207155 seconds_per_epoch,
208156 ) ;
209157
210- self . set_network_head ( network_head_epoch) ;
211- self . set_epochs_behind ( network_head_epoch. saturating_sub ( current_chain_head_epoch) ) ;
158+ self . network_head_epoch = network_head_epoch ;
159+ self . epochs_behind = network_head_epoch. saturating_sub ( current_chain_head_epoch) ;
212160 log:: trace!(
213161 "Sync status report: current head epoch: {}, network head epoch: {}, epochs behind: {}" ,
214162 current_chain_head_epoch,
215163 network_head_epoch,
216- self . get_epochs_behind ( )
164+ self . epochs_behind
217165 ) ;
218166
219167 let time_diff = now_ts. saturating_sub ( heaviest. min_timestamp ( ) ) ;
@@ -228,8 +176,8 @@ impl SyncStatusReport {
228176 }
229177 } ;
230178
231- self . set_status ( status) ;
232- self . update_active_forks ( current_active_forks) ;
179+ self . status = status ;
180+ self . active_forks = current_active_forks;
233181 self . last_updated = now;
234182 }
235183
0 commit comments