-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
llo_provider.go
90 lines (72 loc) · 2.53 KB
/
llo_provider.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package evm
import (
"context"
"errors"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"github.com/smartcontractkit/chainlink-common/pkg/services"
commontypes "github.com/smartcontractkit/chainlink-common/pkg/types"
relaytypes "github.com/smartcontractkit/chainlink-common/pkg/types"
llotypes "github.com/smartcontractkit/chainlink-common/pkg/types/llo"
datastreamsllo "github.com/smartcontractkit/chainlink-data-streams/llo"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/llo"
)
var _ commontypes.LLOProvider = (*lloProvider)(nil)
type lloProvider struct {
cp commontypes.ConfigProvider
transmitter llo.Transmitter
logger logger.Logger
channelDefinitionCache llotypes.ChannelDefinitionCache
ms services.MultiStart
}
func NewLLOProvider(
cp commontypes.ConfigProvider,
transmitter llo.Transmitter,
lggr logger.Logger,
channelDefinitionCache llotypes.ChannelDefinitionCache,
) relaytypes.LLOProvider {
return &lloProvider{
cp,
transmitter,
lggr.Named("LLOProvider"),
channelDefinitionCache,
services.MultiStart{},
}
}
func (p *lloProvider) Start(ctx context.Context) error {
err := p.ms.Start(ctx, p.cp, p.transmitter, p.channelDefinitionCache)
return err
}
func (p *lloProvider) Close() error {
return p.ms.Close()
}
func (p *lloProvider) Ready() error {
return errors.Join(p.cp.Ready(), p.transmitter.Ready(), p.channelDefinitionCache.Ready())
}
func (p *lloProvider) Name() string {
return p.logger.Name()
}
func (p *lloProvider) HealthReport() map[string]error {
report := map[string]error{}
services.CopyHealth(report, p.cp.HealthReport())
services.CopyHealth(report, p.transmitter.HealthReport())
services.CopyHealth(report, p.channelDefinitionCache.HealthReport())
return report
}
func (p *lloProvider) ContractConfigTracker() ocrtypes.ContractConfigTracker {
return p.cp.ContractConfigTracker()
}
func (p *lloProvider) OffchainConfigDigester() ocrtypes.OffchainConfigDigester {
return p.cp.OffchainConfigDigester()
}
func (p *lloProvider) OnchainConfigCodec() datastreamsllo.OnchainConfigCodec {
// TODO: This should probably be moved to core since its chain-specific
// https://smartcontract-it.atlassian.net/browse/MERC-3661
return &datastreamsllo.JSONOnchainConfigCodec{}
}
func (p *lloProvider) ContractTransmitter() llotypes.Transmitter {
return p.transmitter
}
func (p *lloProvider) ChannelDefinitionCache() llotypes.ChannelDefinitionCache {
return p.channelDefinitionCache
}