@@ -36,6 +36,11 @@ type openOptions struct {
36
36
Cache int // the capacity(in megabytes) of the data caching
37
37
Handles int // number of files to be open simultaneously
38
38
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
39
44
}
40
45
41
46
// 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) {
78
83
}
79
84
if o .Type == rawdb .DBPebble || existingDb == rawdb .DBPebble {
80
85
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 )
82
87
}
83
88
if o .Type == rawdb .DBLeveldb || existingDb == rawdb .DBLeveldb {
84
89
log .Info ("Using leveldb as the backing database" )
85
90
return newLevelDBDatabase (o .Directory , o .Cache , o .Handles , o .Namespace , o .ReadOnly )
86
91
}
87
92
// No pre-existing database, no user-requested one either. Default to Pebble.
88
93
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 )
90
95
}
91
96
92
97
// 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
102
107
103
108
// newPebbleDBDatabase creates a persistent key-value database without a freezer
104
109
// 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 )
107
112
if err != nil {
108
113
return nil , err
109
114
}
0 commit comments