@@ -124,8 +124,8 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
124
124
// Configured Tail has changed - get a new one and resolve the diff
125
125
126
126
currentTail , newTail := tail , tail
127
-
128
- if s .Params .SyncFromHash != nil {
127
+ switch {
128
+ case s .Params .SyncFromHash != nil :
129
129
// check first locally if the new Tail exists
130
130
newTail , err = s .store .Get (ctx , s .Params .SyncFromHash )
131
131
if err != nil {
@@ -138,8 +138,16 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
138
138
err ,
139
139
)
140
140
}
141
+ err = s .store .Append (ctx , newTail )
142
+ if err != nil {
143
+ return tail , fmt .Errorf (
144
+ "appending the new tail header(%d): %w" ,
145
+ newTail .Height (),
146
+ err ,
147
+ )
148
+ }
141
149
}
142
- } else if s .Params .SyncFromHeight != 0 {
150
+ case s .Params .SyncFromHeight != 0 :
143
151
// check first locally if the new Tail exists
144
152
newTail , err = s .store .GetByHeight (ctx , s .Params .SyncFromHeight )
145
153
if err != nil {
@@ -152,6 +160,14 @@ func (s *Syncer[H]) Tail(ctx context.Context) (H, error) {
152
160
err ,
153
161
)
154
162
}
163
+ err = s .store .Append (ctx , newTail )
164
+ if err != nil {
165
+ return tail , fmt .Errorf (
166
+ "appending the new tail header(%d): %w" ,
167
+ newTail .Height (),
168
+ err ,
169
+ )
170
+ }
155
171
}
156
172
}
157
173
0 commit comments