@@ -92,6 +92,7 @@ type config struct {
9292 revisions uint
9393 // readCacheStrategy is the caching strategy used for the node cache.
9494 readCacheStrategy CacheStrategy
95+ << << << < HEAD
9596 // rootStoreDir defines a path to store all historical roots on disk.
9697 rootStoreDir string
9798 // logPath is the file path where logs will be written.
@@ -100,6 +101,10 @@ type config struct {
100101 // logFilter is the RUST_LOG format filter string for logging.
101102 // If empty and logPath is set, env_logger defaults will be used.
102103 logFilter string
104+ == == == =
105+ // rootStore defines whether to enable storing all historical revisions on disk.
106+ rootStore bool
107+ >> >> >> > origin / main
103108}
104109
105110func defaultConfig () * config {
@@ -161,13 +166,13 @@ func WithReadCacheStrategy(strategy CacheStrategy) Option {
161166 }
162167}
163168
164- // WithRootStoreDir sets a path to store all historical roots on disk.
169+ // WithRootStore defines whether to enable storing all historical revisions on disk.
165170// When set, historical revisions will be persisted to disk even after being
166171// removed from memory (based on the Revisions limit).
167- // Default: empty string (no disk persistence)
168- func WithRootStoreDir ( dir string ) Option {
172+ // Default: false
173+ func WithRootStore ( ) Option {
169174 return func (c * config ) {
170- c .rootStoreDir = dir
175+ c .rootStore = true
171176 }
172177}
173178
@@ -217,7 +222,7 @@ const (
217222)
218223
219224// New opens or creates a new Firewood database with the given options.
220- // The database file will be created at the provided file path if it does not
225+ // The database directory will be created at the provided path if it does not
221226// already exist.
222227//
223228// If no [Option] is provided, sensible defaults will be used.
@@ -226,7 +231,7 @@ const (
226231// It is the caller's responsibility to call [Database.Close] when the database
227232// is no longer needed. No other [Database] in this process should be opened with
228233// the same file path until the database is closed.
229- func New (filePath string , opts ... Option ) (* Database , error ) {
234+ func New (dbDir string , opts ... Option ) (* Database , error ) {
230235 conf := defaultConfig ()
231236 for _ , opt := range opts {
232237 opt (conf )
@@ -267,13 +272,13 @@ func New(filePath string, opts ...Option) (*Database, error) {
267272 defer pinner .Unpin ()
268273
269274 args := C.struct_DatabaseHandleArgs {
270- path : newBorrowedBytes ([]byte (filePath ), & pinner ),
275+ dir : newBorrowedBytes ([]byte (dbDir ), & pinner ),
271276 cache_size : C .size_t (conf .nodeCacheEntries ),
272277 free_list_cache_size : C .size_t (conf .freeListCacheEntries ),
273278 revisions : C .size_t (conf .revisions ),
274279 strategy : C .uint8_t (conf .readCacheStrategy ),
275280 truncate : C .bool (conf .truncate ),
276- root_store_path : newBorrowedBytes ([] byte ( conf .rootStoreDir ), & pinner ),
281+ root_store : C . bool ( conf .rootStore ),
277282 }
278283
279284 return getDatabaseFromHandleResult (C .fwd_open_db (args ))
0 commit comments