File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ use crate::{
5858 } ,
5959 protocol:: ChunkRangesExt ,
6060 store:: {
61+ gc:: { run_gc, GcConfig } ,
6162 util:: { SizeInfo , SparseMemFile , Tag } ,
6263 IROH_BLOCK_SIZE ,
6364 } ,
@@ -66,7 +67,9 @@ use crate::{
6667} ;
6768
6869#[ derive( Debug , Default ) ]
69- pub struct Options { }
70+ pub struct Options {
71+ pub gc_config : Option < GcConfig > ,
72+ }
7073
7174#[ derive( Debug , Clone ) ]
7275#[ repr( transparent) ]
@@ -113,6 +116,10 @@ impl MemStore {
113116 }
114117
115118 pub fn new ( ) -> Self {
119+ Self :: new_with_opts ( Options :: default ( ) )
120+ }
121+
122+ pub fn new_with_opts ( opts : Options ) -> Self {
116123 let ( sender, receiver) = tokio:: sync:: mpsc:: channel ( 32 ) ;
117124 tokio:: spawn (
118125 Actor {
@@ -130,7 +137,13 @@ impl MemStore {
130137 }
131138 . run ( ) ,
132139 ) ;
133- Self :: from_sender ( sender. into ( ) )
140+
141+ let store = Self :: from_sender ( sender. into ( ) ) ;
142+ if let Some ( gc_config) = opts. gc_config {
143+ tokio:: spawn ( run_gc ( store. deref ( ) . clone ( ) , gc_config) ) ;
144+ }
145+
146+ store
134147 }
135148}
136149
You can’t perform that action at this time.
0 commit comments