@@ -163,6 +163,7 @@ func (m *Module) sync(ctx context.Context) error {
163163 if m .state .ChangeId >= changes .Changes [i ].ChangeID {
164164 continue
165165 }
166+ lastId = changes .Changes [i ].ChangeID
166167
167168 status , err := storage .ParseStatus (changes .Changes [i ].Status )
168169 if err != nil {
@@ -187,17 +188,19 @@ func (m *Module) sync(ctx context.Context) error {
187188 ChangeId : changes .Changes [i ].ChangeID ,
188189 Status : status ,
189190 }
190- lastId = changes .Changes [i ].ChangeID
191191 }
192192
193- m .state .ChangeId = lastId
194- if err := m .save (ctx , cids , addressIds ); err != nil {
195- return errors .Wrap (err , "save" )
193+ if lastId > m .state .ChangeId {
194+ m .state .ChangeId = lastId
195+
196+ if err := m .save (ctx , cids , addressIds ); err != nil {
197+ return errors .Wrap (err , "save" )
198+ }
199+ log .Debug ().
200+ Int ("changes_count" , len (cids )).
201+ Int64 ("head" , m .state .ChangeId ).
202+ Msg ("saved changes" )
196203 }
197- log .Debug ().
198- Int ("changes_count" , len (cids )).
199- Int64 ("head" , m .state .ChangeId ).
200- Msg ("saved changes" )
201204
202205 end = len (changes .Changes ) < int (m .limit )
203206 }
0 commit comments