File tree Expand file tree Collapse file tree 3 files changed +12
-9
lines changed
cli/subcommands/chain_cmd Expand file tree Collapse file tree 3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 2727forest_check_db_stats
2828echo " Run snapshot GC"
2929forest_run_snap_gc
30- sleep 5
30+ forest_wait_api
3131echo " Wait the node to sync"
3232forest_wait_for_sync
3333forest_check_db_stats
Original file line number Diff line number Diff line change @@ -8,15 +8,18 @@ use std::time::Duration;
88#[ derive( Debug , Subcommand ) ]
99pub enum ChainPruneCommands {
1010 /// Run snapshot GC
11- Snap ,
11+ Snap {
12+ #[ arg( long) ]
13+ no_wait : bool ,
14+ } ,
1215}
1316
1417impl ChainPruneCommands {
1518 pub async fn run ( self , client : rpc:: Client ) -> anyhow:: Result < ( ) > {
1619 match self {
17- Self :: Snap => {
20+ Self :: Snap { no_wait } => {
1821 client
19- . call ( ChainPruneSnapshot :: request ( ( ) ) ?. with_timeout ( Duration :: MAX ) )
22+ . call ( ChainPruneSnapshot :: request ( ( !no_wait , ) ) ?. with_timeout ( Duration :: MAX ) )
2023 . await ?;
2124 }
2225 }
Original file line number Diff line number Diff line change @@ -196,22 +196,22 @@ impl RpcMethod<1> for ChainGetMessagesInTipset {
196196}
197197
198198pub enum ChainPruneSnapshot { }
199- impl RpcMethod < 0 > for ChainPruneSnapshot {
199+ impl RpcMethod < 1 > for ChainPruneSnapshot {
200200 const NAME : & ' static str = "Forest.SnapshotGC" ;
201- const PARAM_NAMES : [ & ' static str ; 0 ] = [ ] ;
201+ const PARAM_NAMES : [ & ' static str ; 1 ] = [ "blocking" ] ;
202202 const API_PATHS : BitFlags < ApiPaths > = ApiPaths :: all ( ) ;
203203 const PERMISSION : Permission = Permission :: Admin ;
204204
205- type Params = ( ) ;
205+ type Params = ( bool , ) ;
206206 type Ok = ( ) ;
207207
208208 async fn handle (
209209 _ctx : Ctx < impl Blockstore + Send + Sync + ' static > ,
210- ( ) : Self :: Params ,
210+ ( blocking , ) : Self :: Params ,
211211 ) -> Result < Self :: Ok , ServerError > {
212212 if let Some ( gc) = crate :: daemon:: GLOBAL_SNAPSHOT_GC . get ( ) {
213213 let progress_rx = gc. trigger ( ) ;
214- while progress_rx. recv_async ( ) . await . is_ok ( ) { }
214+ while blocking && progress_rx. recv_async ( ) . await . is_ok ( ) { }
215215 Ok ( ( ) )
216216 } else {
217217 Err ( anyhow:: anyhow!( "snapshot gc is not enabled" ) . into ( ) )
You can’t perform that action at this time.
0 commit comments