-
Notifications
You must be signed in to change notification settings - Fork 0
/
relayer.go
62 lines (50 loc) · 1.45 KB
/
relayer.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 relayer
import (
"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/vitwit/avail-da-module/relayer/avail"
"github.com/vitwit/avail-da-module/relayer/local"
"github.com/vitwit/avail-da-module/x/cada/types"
)
// Relayer is responsible for posting new blocks to Avail
type Relayer struct {
Logger log.Logger
provenHeights chan int64
commitHeights chan int64
submittedBlocksCache map[int64]bool
CosmosProvider local.CosmosProvider
AvailDAClient avail.DA
clientCtx client.Context
AvailConfig types.AvailConfiguration
NodeDir string
}
// NewRelayer creates a new Relayer instance
func NewRelayer(
logger log.Logger,
cdc codec.BinaryCodec,
cfg types.AvailConfiguration,
nodeDir string,
daClient avail.DA,
) (*Relayer, error) {
// local sdk-based chain provider
localProvider, err := local.NewDefaultCosmosProvider(cdc, cfg.CosmosNodeRPC)
if err != nil {
return nil, err
}
return &Relayer{
Logger: logger,
provenHeights: make(chan int64, 10000),
commitHeights: make(chan int64, 10000),
CosmosProvider: localProvider,
// availChainID: cfg.ChainID,
submittedBlocksCache: make(map[int64]bool),
NodeDir: nodeDir,
AvailConfig: cfg,
AvailDAClient: daClient,
}, nil
}
// SetClientContext sets the provided client context for the Relayer.
func (r *Relayer) SetClientContext(clientCtx client.Context) {
r.clientCtx = clientCtx
}