Skip to content

Commit

Permalink
[actpool] refactor actionstore config (#4473)
Browse files Browse the repository at this point in the history
Co-authored-by: dustinxie <[email protected]>
  • Loading branch information
envestcc and dustinxie authored Nov 1, 2024
1 parent 4c562c3 commit 679f001
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
11 changes: 5 additions & 6 deletions actpool/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ var (
BlackList: []string{},
MaxNumBlobsPerAcct: 16,
Store: &StoreConfig{
Store: actionStoreConfig{
Datadir: "/var/data/actpool.cache",
Datacap: 1024 * 1024 * 100, // 100MB
},
Datadir: "/var/data/actpool.cache",
Datacap: 1024 * 1024 * 100, // 100MB
ReadInterval: 10 * time.Minute,
},
}
Expand Down Expand Up @@ -62,6 +60,7 @@ func (ap Config) MinGasPrice() *big.Int {

// StoreConfig is the configuration for the blob store
type StoreConfig struct {
Store actionStoreConfig `yaml:"store"`
ReadInterval time.Duration `yaml:"readInterval"` // Interval to read from store to actpool memory
Datadir string `yaml:"datadir"` // Data directory containing the currently executable blobs
Datacap uint64 `yaml:"datacap"` // Soft-cap of database storage (hard cap is larger due to overhead)
ReadInterval time.Duration `yaml:"readInterval"` // Interval to read from store to actpool memory
}
5 changes: 4 additions & 1 deletion actpool/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ func WithStore(cfg StoreConfig, encode encodeAction, decode decodeAction) func(*
if encode == nil || decode == nil {
return errors.New("encode and decode functions must be provided")
}
store, err := newActionStore(cfg.Store, encode, decode)
store, err := newActionStore(actionStoreConfig{
Datadir: cfg.Datadir,
Datacap: cfg.Datacap,
}, encode, decode)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions e2etest/e2etest.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func initDBPaths(r *require.Assertions, cfg *config.Config) {
if cfg.ActPool.Store != nil {
testActionStorePath, err := os.MkdirTemp(os.TempDir(), "actionstore")
r.NoError(err)
cfg.ActPool.Store.Store.Datadir = testActionStorePath
cfg.ActPool.Store.Datadir = testActionStorePath
}
}

Expand All @@ -383,6 +383,6 @@ func clearDBPaths(cfg *config.Config) {
testutil.CleanupPath(cfg.Consensus.RollDPoS.ConsensusDBPath)
testutil.CleanupPath(cfg.Chain.BlobStoreDBPath)
if cfg.ActPool.Store != nil {
testutil.CleanupPath(cfg.ActPool.Store.Store.Datadir)
testutil.CleanupPath(cfg.ActPool.Store.Datadir)
}
}
2 changes: 1 addition & 1 deletion server/itx/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func newConfig(t *testing.T) (config.Config, func()) {
cfg.Chain.BlobStoreDBPath = blobPath
cfg.Chain.ContractStakingIndexDBPath = contractIndexPath
if cfg.ActPool.Store != nil {
cfg.ActPool.Store.Store.Datadir = testActionStorePath
cfg.ActPool.Store.Datadir = testActionStorePath
}
return cfg, func() {
testutil.CleanupPath(dbPath)
Expand Down

0 comments on commit 679f001

Please sign in to comment.