Skip to content

Commit

Permalink
bus: use maxSyncTime to decide whether the bus is synced or not
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed May 13, 2024
1 parent 620c9f7 commit 4560593
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import (
"go.uber.org/zap"
)

// blockInterval is the expected wall clock time between consecutive blocks.
const blockInterval = 10 * time.Minute
// maxSyncTime is the maximum time since the last block before we consider
// ourselves unsynced.
const maxSyncTime = time.Hour

// Client re-exports the client from the client package.
type Client struct {
Expand Down Expand Up @@ -1788,7 +1789,7 @@ func (b *bus) consensusState(ctx context.Context) (api.ConsensusState, error) {

var synced bool
block, found := b.cm.Block(index.ID)
if found && time.Since(block.Timestamp) < 2*blockInterval {
if found && time.Since(block.Timestamp) <= maxSyncTime {
synced = true
}

Expand Down

0 comments on commit 4560593

Please sign in to comment.