Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Development remove extra substrate connection #1286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions monitoring-bot/internal/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import (
"github.com/cosmos/go-bip39"
"github.com/rs/zerolog/log"
client "github.com/threefoldtech/tfchain/clients/tfchain-client-go"
substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go"
"github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go/peer"
)

type address string
type network string
type (
address string
network string
)

type config struct {
testMnemonic string `env:"TESTNET_MNEMONIC"`
Expand Down Expand Up @@ -364,7 +367,8 @@ func (m *Monitor) systemVersion(ctx context.Context) (map[network]version, map[n

for _, NodeID := range randomNodes {
log.Debug().Msgf("check node %d", NodeID)
ver, working, failed, err := m.checkNodeSystemVersion(ctx, NodeID, network)
ver, working, failed, err := m.checkNodeSystemVersion(ctx, con, NodeID, network)

failedNodes[network] = append(failedNodes[network], failed...)
if err != nil {
log.Error().Err(err).Msgf("check node %d failed", NodeID)
Expand All @@ -379,18 +383,12 @@ func (m *Monitor) systemVersion(ctx context.Context) (map[network]version, map[n
return versions, workingNodes, failedNodes
}

func (m *Monitor) checkNodeSystemVersion(ctx context.Context, NodeID uint32, net network) (version, []uint32, []uint32, error) {
func (m *Monitor) checkNodeSystemVersion(ctx context.Context, con *substrate.Substrate, NodeID uint32, net network) (version, []uint32, []uint32, error) {
const cmd = "zos.system.version"
var ver version
var workingNodes []uint32
var failedNodes []uint32

con, err := m.managers[net].Substrate()
if err != nil {
return version{}, []uint32{}, []uint32{}, fmt.Errorf("substrate connection for %v network failed with error: %w", NodeID, err)
}
defer con.Close()

node, err := con.GetNode(NodeID)
if err != nil {
failedNodes = append(failedNodes, NodeID)
Expand Down
6 changes: 0 additions & 6 deletions rmb-sdk-go/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ func NewPeer(

if !bytes.Equal(twin.E2EKey, publicKey) || twin.Relay == nil || joinURLs != *twin.Relay {
log.Info().Str("Relay url/s", joinURLs).Msg("twin relay/public key didn't match, updating on chain ...")
subConn, err := subManager.Substrate()
if err != nil {
return nil, errors.Wrap(err, "could not start substrate connection")
}
defer subConn.Close()

if _, err = subConn.UpdateTwin(identity, joinURLs, publicKey); err != nil {
return nil, errors.Wrap(err, "could not update twin relay information")
}
Expand Down
Loading