-
Notifications
You must be signed in to change notification settings - Fork 2
/
module.go
62 lines (52 loc) · 1.43 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
53
54
55
56
57
58
59
60
61
62
package staking
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/rs/zerolog"
grpcClient "github.com/bro-n-bro/spacebox-crawler/client/grpc"
"github.com/bro-n-bro/spacebox-crawler/modules/utils"
tb "github.com/bro-n-bro/spacebox-crawler/pkg/mapper/to_broker"
"github.com/bro-n-bro/spacebox-crawler/types"
)
const (
ModuleName = "staking"
)
var (
_ types.Module = &Module{}
_ types.GenesisHandler = &Module{}
_ types.BlockHandler = &Module{}
_ types.MessageHandler = &Module{}
_ types.ValidatorsHandler = &Module{}
)
type (
AccountCache[K, V comparable] interface {
UpdateCacheValue(K, V) bool
}
Module struct {
log *zerolog.Logger
client *grpcClient.Client
broker broker
tbM tb.ToBroker
cdc codec.Codec
defaultDenom string
accCache AccountCache[string, int64]
enabledModules []string // xxx fixme
}
)
func New(b broker, cli *grpcClient.Client, tbM tb.ToBroker, cdc codec.Codec, modules []string, defaultDenom string) *Module {
return &Module{
log: utils.NewModuleLogger(ModuleName),
broker: b,
client: cli,
tbM: tbM,
cdc: cdc,
enabledModules: modules,
defaultDenom: defaultDenom,
}
}
func (m *Module) Name() string { return ModuleName }
func (m *Module) WithAccountCache(cache AccountCache[string, int64]) *Module {
if cache != nil {
m.accCache = cache
}
return m
}