switch DAGStoreConfig#GCInterval to Duration type.

This commit is contained in:
Raúl Kripalani 2021-08-04 12:20:51 +01:00
parent 35895e897a
commit 583a3c6277
4 changed files with 14 additions and 13 deletions

View File

@ -90,7 +90,7 @@ func NewDAGStore(cfg config.DAGStoreConfig, mountApi MinerAPI) (*dagstore.DAGSto
mountApi: mountApi, mountApi: mountApi,
failureCh: failureCh, failureCh: failureCh,
traceCh: traceCh, traceCh: traceCh,
gcInterval: time.Duration(cfg.GCIntervalMillis) * time.Millisecond, gcInterval: time.Duration(cfg.GCInterval),
} }
return dagst, w, nil return dagst, w, nil

View File

@ -29,10 +29,10 @@ func TestWrapperAcquireRecovery(t *testing.T) {
// Create a DAG store wrapper // Create a DAG store wrapper
dagst, w, err := NewDAGStore(config.DAGStoreConfig{ dagst, w, err := NewDAGStore(config.DAGStoreConfig{
TransientsDir: t.TempDir(), TransientsDir: t.TempDir(),
IndexDir: t.TempDir(), IndexDir: t.TempDir(),
DatastoreDir: t.TempDir(), DatastoreDir: t.TempDir(),
GCIntervalMillis: 1, GCInterval: config.Duration(1 * time.Millisecond),
}, mockLotusMount{}) }, mockLotusMount{})
require.NoError(t, err) require.NoError(t, err)
@ -82,10 +82,10 @@ func TestWrapperBackground(t *testing.T) {
// Create a DAG store wrapper // Create a DAG store wrapper
dagst, w, err := NewDAGStore(config.DAGStoreConfig{ dagst, w, err := NewDAGStore(config.DAGStoreConfig{
TransientsDir: t.TempDir(), TransientsDir: t.TempDir(),
IndexDir: t.TempDir(), IndexDir: t.TempDir(),
DatastoreDir: t.TempDir(), DatastoreDir: t.TempDir(),
GCIntervalMillis: 1, GCInterval: config.Duration(1 * time.Millisecond),
}, mockLotusMount{}) }, mockLotusMount{})
require.NoError(t, err) require.NoError(t, err)

View File

@ -195,7 +195,7 @@ func DefaultStorageMiner() *StorageMiner {
MaxConcurrentIndex: 5, MaxConcurrentIndex: 5,
MaxConcurrentReadyFetches: 2, MaxConcurrentReadyFetches: 2,
MaxConcurrencyStorageCalls: 100, MaxConcurrencyStorageCalls: 100,
GCIntervalMillis: 60000, GCInterval: Duration(1 * time.Minute),
}, },
} }
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http" cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"

View File

@ -86,9 +86,10 @@ type DAGStoreConfig struct {
// Default value: 100. // Default value: 100.
MaxConcurrencyStorageCalls int MaxConcurrencyStorageCalls int
// The number of milliseconds between calls to periodic dagstore GC. // The time between calls to periodic dagstore GC, in time.Duration string
// Default value: 60000 (60 seconds = 1 minute). // representation, e.g. 1m, 5m, 1h.
GCIntervalMillis int // Default value: 1 minute.
GCInterval Duration
} }
type MinerSubsystemConfig struct { type MinerSubsystemConfig struct {