Disable GC on chain badger datastore

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-09-01 20:39:58 +02:00
parent b8bbbf3ea3
commit 997d49b63f
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -17,7 +17,7 @@ import (
type dsCtor func(path string) (datastore.Batching, error)
var fsDatastores = map[string]dsCtor{
"chain": badgerDs,
"chain": chainBadgerDs,
"metadata": levelDs,
// Those need to be fast for large writes... but also need a really good GC :c
@ -26,6 +26,16 @@ var fsDatastores = map[string]dsCtor{
"client": badgerDs, // client specific
}
func chainBadgerDs(path string) (datastore.Batching, error) {
opts := badger.DefaultOptions
opts.GcInterval = 0 // disable GC for chain datastore
opts.Options = dgbadger.DefaultOptions("").WithTruncate(true).
WithValueThreshold(1 << 10)
return badger.NewDatastore(path, &opts)
}
func badgerDs(path string) (datastore.Batching, error) {
opts := badger.DefaultOptions
opts.Options = dgbadger.DefaultOptions("").WithTruncate(true).