Skip to content

Commit b569828

Browse files
committed
refine logs/metrics
1 parent abe56c1 commit b569828

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

sync/sync_head.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
7070
case errors.Is(err, header.ErrEmptyStore):
7171
// Store is empty, likely the first start - initialize.
7272
log.Info("empty store, initializing...")
73-
// TODO(@Wondertan): Requesting the head directly from the network instead of
74-
// calling general Head path. This is a temporary solution needed to ensure Tail is written to the store first
75-
// before Head. To be reworked by bsync.
73+
// TODO(@Wondertan): Copying the initialization logic here instead of calling the general Head path.
74+
// This is a temporary solution needed to ensure Tail is written to the store first before Head.
75+
// To be reworked by bsync.
7676
head, err := s.head.Head(ctx)
7777
if err != nil {
7878
return head, fmt.Errorf("requesting network head: %w", err)
7979
}
80+
s.metrics.subjectiveInitialization(s.ctx)
8081

8182
switch {
8283
case s.Params.SyncFromHash != nil:
@@ -111,9 +112,7 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
111112
return tail, fmt.Errorf("applying head from trusted peers: %w", err)
112113
}
113114

114-
log.Infof("initialized with Tail %d and Head %d", tail.Height(), head.Height())
115-
116-
// TODO: Make sure all the metrics for this alternative subjective init path are added
115+
log.Infow("subjective initialization finished", "tail_height", tail.Height(), "head_height", head.Height())
117116

118117
case !tail.IsZero() && !s.isTailActual(tail):
119118
// Configured Tail has changed - get a new one and resolve the diff
@@ -152,7 +151,7 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
152151

153152
switch {
154153
case currentTail.Height() > newTail.Height():
155-
log.Infow(
154+
log.Infof(
156155
"tail header changed from %d to %d, syncing the diff...",
157156
currentTail,
158157
newTail,
@@ -165,8 +164,8 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
165164
return tail, fmt.Errorf("syncing the diff between old and new Tail: %w", err)
166165
}
167166
case currentTail.Height() < newTail.Height():
168-
log.Infow(
169-
"Tail header changed from %d to %d, pruning the diff...",
167+
log.Infof(
168+
"tail header changed from %d to %d, pruning the diff...",
170169
currentTail,
171170
newTail,
172171
)

0 commit comments

Comments
 (0)