Skip to content
Merged
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
17 changes: 14 additions & 3 deletions chains/heads/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ChainConfig interface {
FinalityDepth() uint32
SafeDepth() uint32
FinalityTagEnabled() bool
SafeTagSupported() bool
FinalizedBlockOffset() uint32
}

Expand Down Expand Up @@ -402,9 +403,19 @@ func (t *tracker[HTH, S, ID, BHASH]) backfillLoop(ctx context.Context) {

func (t *tracker[HTH, S, ID, BHASH]) LatestSafeBlock(ctx context.Context) (safe HTH, err error) {
if t.config.FinalityTagEnabled() {
latestSafe, err2 := t.client.LatestSafeBlock(ctx)
if err2 != nil {
return latestSafe, fmt.Errorf("failed to get latest finalized block: %w", err2)
var latestSafe HTH
if t.config.SafeTagSupported() {
latestSafe, err = t.client.LatestSafeBlock(ctx)
if err != nil {
return latestSafe, fmt.Errorf("failed to get latest finalized block: %w", err)
}
} else {
// return latest finalized block if safe tag is not enabled
_, finalized, err2 := t.LatestAndFinalizedBlock(ctx)
if err2 != nil {
return finalized, fmt.Errorf("failed to get latest finalized block: %w", err2)
}
latestSafe = finalized
}

if !latestSafe.IsValid() {
Expand Down
Loading