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,33 +256,35 @@ func (e *Watcher) Run(ctx context.Context) error {
return return
} }
for { if e.next_round < status.NextVersionRound {
logger.Info(fmt.Sprintf("Algorand next_round set to %d", e.next_round)) for {
block, err := algodClient.Block(e.next_round).Do(context.Background()) logger.Info(fmt.Sprintf("inspecting block %d", e.next_round))
if err != nil { block, err := algodClient.Block(e.next_round).Do(context.Background())
if strings.Contains(err.Error(), "ledger does not have entry") { if err != nil {
logger.Error(fmt.Sprintf("algodClient.Block %d: %s", e.next_round, err.Error()))
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDAlgorand, 1)
errC <- err
return
}
if block.Round == 0 {
break break
} }
logger.Error(fmt.Sprintf("algodClient.Block %d: %s", e.next_round, err.Error()))
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDAlgorand, 1) for _, element := range block.Payset {
errC <- err lookAtTxn(e, element, block, logger)
return }
e.next_round = e.next_round + 1
if e.next_round == status.NextVersionRound {
break
}
} }
if block.Round == 0 {
break
}
for _, element := range block.Payset {
lookAtTxn(e, element, block, logger)
}
e.next_round = e.next_round + 1
} }
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),
}) })
} }