algo/watcher: Fixes for testnet

This commit is contained in:
Josh Siegel 2022-06-07 10:56:49 +00:00 committed by jumpsiegel
parent 8875735581
commit 594674db5e
1 changed files with 22 additions and 21 deletions

View File

@ -21,7 +21,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
"go.uber.org/zap" "go.uber.org/zap"
"strings"
"time" "time"
) )
@ -257,13 +256,11 @@ func (e *Watcher) Run(ctx context.Context) error {
return return
} }
if e.next_round < status.NextVersionRound {
for { for {
logger.Info(fmt.Sprintf("Algorand next_round set to %d", e.next_round)) logger.Info(fmt.Sprintf("inspecting block %d", e.next_round))
block, err := algodClient.Block(e.next_round).Do(context.Background()) block, err := algodClient.Block(e.next_round).Do(context.Background())
if err != nil { if err != nil {
if strings.Contains(err.Error(), "ledger does not have entry") {
break
}
logger.Error(fmt.Sprintf("algodClient.Block %d: %s", e.next_round, err.Error())) logger.Error(fmt.Sprintf("algodClient.Block %d: %s", e.next_round, err.Error()))
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDAlgorand, 1) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDAlgorand, 1)
@ -279,11 +276,15 @@ func (e *Watcher) Run(ctx context.Context) error {
lookAtTxn(e, element, block, logger) lookAtTxn(e, element, block, logger)
} }
e.next_round = e.next_round + 1 e.next_round = e.next_round + 1
if e.next_round == status.NextVersionRound {
break
}
}
} }
readiness.SetReady(common.ReadinessAlgorandSyncing) readiness.SetReady(common.ReadinessAlgorandSyncing)
currentAlgorandHeight.Set(float64(e.next_round - 1)) currentAlgorandHeight.Set(float64(e.next_round))
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDAlgorand, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDAlgorand, &gossipv1.Heartbeat_Network{
Height: int64(e.next_round - 1), Height: int64(e.next_round),
ContractAddress: fmt.Sprintf("%d", e.appid), ContractAddress: fmt.Sprintf("%d", e.appid),
}) })
} }