Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(sync): drop storeHeaders helper #193

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (s *Syncer[H]) processHeaders(
}

// apply cached headers
if err = s.storeHeaders(ctx, headers...); err != nil {
if err := s.store.Append(ctx, headers...); err != nil {
return err
}

Expand Down Expand Up @@ -325,7 +325,7 @@ func (s *Syncer[H]) requestHeaders(
return err
}

if err := s.storeHeaders(ctx, headers...); err != nil {
if err := s.store.Append(ctx, headers...); err != nil {
return err
}

Expand All @@ -334,14 +334,3 @@ func (s *Syncer[H]) requestHeaders(
}
return nil
}

// storeHeaders updates store with new headers and updates current syncStore's Head.
func (s *Syncer[H]) storeHeaders(ctx context.Context, headers ...H) error {
// we don't expect any issues in storing right now, as all headers are now verified.
// So, we should return immediately in case an error appears.
err := s.store.Append(ctx, headers...)
if err != nil {
return err
}
return nil
}
2 changes: 1 addition & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (s *Syncer[H]) setSubjectiveHead(ctx context.Context, netHead H) {
// * Allow storing any valid header here in Store
// * Remove ErrNonAdjacent
// * Remove writeHead from the canonical store implementation
err := s.storeHeaders(ctx, netHead)
err := s.store.Append(ctx, netHead)
var nonAdj *header.ErrNonAdjacent
if err != nil && !errors.As(err, &nonAdj) {
// might be a storage error or something else, but we can still try to continue processing netHead
Expand Down
Loading