-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnode_config.go
More file actions
40 lines (34 loc) · 982 Bytes
/
node_config.go
File metadata and controls
40 lines (34 loc) · 982 Bytes
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
package monitoring
import (
"encoding/json"
"fmt"
"io"
relayMonitoring "github.com/smartcontractkit/chainlink-common/pkg/monitoring"
"github.com/smartcontractkit/libocr/offchainreporting2/types"
)
type CosmosNodeConfig struct {
ID string `json:"id,omitempty"`
NodeAddress []string `json:"nodeAddress,omitempty"`
}
func (t CosmosNodeConfig) GetName() string {
return t.ID
}
func (t CosmosNodeConfig) GetAccount() types.Account {
address := ""
if len(t.NodeAddress) != 0 {
address = t.NodeAddress[0]
}
return types.Account(address)
}
func CosmosNodesParser(buf io.ReadCloser) ([]relayMonitoring.NodeConfig, error) {
rawNodes := []CosmosNodeConfig{}
decoder := json.NewDecoder(buf)
if err := decoder.Decode(&rawNodes); err != nil {
return nil, fmt.Errorf("unable to unmarshal nodes config data: %w", err)
}
nodes := make([]relayMonitoring.NodeConfig, len(rawNodes))
for i, rawNode := range rawNodes {
nodes[i] = rawNode
}
return nodes, nil
}