File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -377,8 +377,8 @@ impl From<multiaddr::Error> for ParseErr {
377377 }
378378}
379379
380- #[ derive( Clone , Debug , Eq , PartialEq ) ]
381380/// Sync operation mode.
381+ #[ derive( Clone , Debug , Eq , PartialEq ) ]
382382pub enum SyncMode {
383383 /// Full block download and verification.
384384 Full ,
@@ -393,6 +393,18 @@ pub enum SyncMode {
393393 Warp ,
394394}
395395
396+ impl SyncMode {
397+ /// Returns if `self` is [`Self::Warp`].
398+ pub fn is_warp ( & self ) -> bool {
399+ matches ! ( self , Self :: Warp )
400+ }
401+
402+ /// Returns if `self` is [`Self::Fast`].
403+ pub fn is_fast ( & self ) -> bool {
404+ matches ! ( self , Self :: Fast { .. } )
405+ }
406+ }
407+
396408impl Default for SyncMode {
397409 fn default ( ) -> Self {
398410 Self :: Full
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ use sc_executor::RuntimeVersionOf;
3939use sc_keystore:: LocalKeystore ;
4040use sc_network:: {
4141 block_request_handler:: { self , BlockRequestHandler } ,
42- config:: Role ,
42+ config:: { Role , SyncMode } ,
4343 light_client_requests:: { self , handler:: LightClientRequestHandler } ,
4444 state_request_handler:: { self , StateRequestHandler } ,
4545 warp_request_handler:: { self , RequestHandler as WarpSyncRequestHandler , WarpSyncProvider } ,
@@ -767,6 +767,18 @@ where
767767 warp_sync,
768768 } = params;
769769
770+ if warp_sync. is_none ( ) && config. network . sync_mode . is_warp ( ) {
771+ return Err ( "Warp sync enabled, but no warp sync provider configured." . into ( ) )
772+ }
773+
774+ if config. state_pruning . is_archive ( ) {
775+ match config. network . sync_mode {
776+ SyncMode :: Fast { .. } => return Err ( "Fast sync doesn't work for archive nodes" . into ( ) ) ,
777+ SyncMode :: Warp => return Err ( "Warp sync doesn't work for archive nodes" . into ( ) ) ,
778+ SyncMode :: Full => { } ,
779+ } ;
780+ }
781+
770782 let transaction_pool_adapter = Arc :: new ( TransactionPoolAdapter {
771783 imports_external_transactions : !matches ! ( config. role, Role :: Light ) ,
772784 pool : transaction_pool,
You can’t perform that action at this time.
0 commit comments