@@ -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,13 @@ 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 (
116
+ "subjective initialization finished" ,
117
+ "tail_height" ,
118
+ tail .Height (),
119
+ "head_height" ,
120
+ head .Height (),
121
+ )
117
122
118
123
case ! tail .IsZero () && ! s .isTailActual (tail ):
119
124
// Configured Tail has changed - get a new one and resolve the diff
@@ -152,7 +157,7 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
152
157
153
158
switch {
154
159
case currentTail .Height () > newTail .Height ():
155
- log .Infow (
160
+ log .Infof (
156
161
"tail header changed from %d to %d, syncing the diff..." ,
157
162
currentTail ,
158
163
newTail ,
@@ -165,8 +170,8 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
165
170
return tail , fmt .Errorf ("syncing the diff between old and new Tail: %w" , err )
166
171
}
167
172
case currentTail .Height () < newTail .Height ():
168
- log .Infow (
169
- "Tail header changed from %d to %d, pruning the diff..." ,
173
+ log .Infof (
174
+ "tail header changed from %d to %d, pruning the diff..." ,
170
175
currentTail ,
171
176
newTail ,
172
177
)
0 commit comments