@@ -36,6 +36,11 @@ type openOptions struct {
3636 Cache int // the capacity(in megabytes) of the data caching
3737 Handles int // number of files to be open simultaneously
3838 ReadOnly bool
39+
40+ // Ephemeral means that filesystem sync operations should be avoided:
41+ // data integrity in the face of a crash is not important. This option
42+ // should typically be used in tests.
43+ Ephemeral bool
3944}
4045
4146// openDatabase opens both a disk-based key-value database such as leveldb or pebble, but also
@@ -78,15 +83,15 @@ func openKeyValueDatabase(o openOptions) (ethdb.Database, error) {
7883 }
7984 if o .Type == rawdb .DBPebble || existingDb == rawdb .DBPebble {
8085 log .Info ("Using pebble as the backing database" )
81- return newPebbleDBDatabase (o .Directory , o .Cache , o .Handles , o .Namespace , o .ReadOnly )
86+ return newPebbleDBDatabase (o .Directory , o .Cache , o .Handles , o .Namespace , o .ReadOnly , o . Ephemeral )
8287 }
8388 if o .Type == rawdb .DBLeveldb || existingDb == rawdb .DBLeveldb {
8489 log .Info ("Using leveldb as the backing database" )
8590 return newLevelDBDatabase (o .Directory , o .Cache , o .Handles , o .Namespace , o .ReadOnly )
8691 }
8792 // No pre-existing database, no user-requested one either. Default to Pebble.
8893 log .Info ("Defaulting to pebble as the backing database" )
89- return newPebbleDBDatabase (o .Directory , o .Cache , o .Handles , o .Namespace , o .ReadOnly )
94+ return newPebbleDBDatabase (o .Directory , o .Cache , o .Handles , o .Namespace , o .ReadOnly , o . Ephemeral )
9095}
9196
9297// newLevelDBDatabase creates a persistent key-value database without a freezer
@@ -102,8 +107,8 @@ func newLevelDBDatabase(file string, cache int, handles int, namespace string, r
102107
103108// newPebbleDBDatabase creates a persistent key-value database without a freezer
104109// moving immutable chain segments into cold storage.
105- func newPebbleDBDatabase (file string , cache int , handles int , namespace string , readonly bool ) (ethdb.Database , error ) {
106- db , err := pebble .New (file , cache , handles , namespace , readonly )
110+ func newPebbleDBDatabase (file string , cache int , handles int , namespace string , readonly bool , ephemeral bool ) (ethdb.Database , error ) {
111+ db , err := pebble .New (file , cache , handles , namespace , readonly , ephemeral )
107112 if err != nil {
108113 return nil , err
109114 }
0 commit comments