forked from forbole/juno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
52 lines (42 loc) · 1.07 KB
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package pruning
import (
"github.com/chain4energy/juno/v4/types/config"
"github.com/chain4energy/juno/v4/logging"
"github.com/chain4energy/juno/v4/database"
"github.com/chain4energy/juno/v4/modules"
)
var (
_ modules.Module = &Module{}
_ modules.BlockModule = &Module{}
_ modules.AdditionalOperationsModule = &Module{}
)
// Module represents the pruning module allowing to clean the database periodically
type Module struct {
cfg *Config
db database.Database
logger logging.Logger
}
// NewModule builds a new Module instance
func NewModule(cfg config.Config, db database.Database, logger logging.Logger) *Module {
bz, err := cfg.GetBytes()
if err != nil {
panic(err)
}
pruningCfg, err := ParseConfig(bz)
if err != nil {
panic(err)
}
return &Module{
cfg: pruningCfg,
db: db,
logger: logger,
}
}
// Name implements modules.Module
func (m *Module) Name() string {
return "pruning"
}
// RunAdditionalOperations implements
func (m *Module) RunAdditionalOperations() error {
return RunAdditionalOperations(m.cfg)
}