@@ -70,13 +70,14 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
70
70
case errors .Is (err , header .ErrEmptyStore ):
71
71
// Store is empty, likely the first start - initialize.
72
72
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.
76
76
head , err := s .head .Head (ctx )
77
77
if err != nil {
78
78
return head , fmt .Errorf ("requesting network head: %w" , err )
79
79
}
80
+ s .metrics .subjectiveInitialization (s .ctx )
80
81
81
82
switch {
82
83
case s .Params .SyncFromHash != nil :
@@ -111,9 +112,7 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
111
112
return tail , fmt .Errorf ("applying head from trusted peers: %w" , err )
112
113
}
113
114
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 ())
117
116
118
117
case ! tail .IsZero () && ! s .isTailActual (tail ):
119
118
// 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) {
152
151
153
152
switch {
154
153
case currentTail .Height () > newTail .Height ():
155
- log .Infow (
154
+ log .Infof (
156
155
"tail header changed from %d to %d, syncing the diff..." ,
157
156
currentTail ,
158
157
newTail ,
@@ -165,8 +164,8 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
165
164
return tail , fmt .Errorf ("syncing the diff between old and new Tail: %w" , err )
166
165
}
167
166
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..." ,
170
169
currentTail ,
171
170
newTail ,
172
171
)
0 commit comments