Skip to content

Conversation

@marino39
Copy link
Contributor

… been written


func (w *writerWithVerifyHash[T]) Write(ctx context.Context, b Block[T]) error {
// Skip if block is already written
if b.Number <= w.Writer.BlockNum() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to keep behaviour in line with other Writer implementations.


// Validate parent hash
if b.Parent != w.prevHash {
w.prevHash = common.Hash{}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work as previous block may still be in memory and pending being written to s3. So it's better to keep prevHash and try to match next time someones writes.

@marino39 marino39 merged commit b4148f6 into master Oct 21, 2025
1 check passed
@marino39 marino39 deleted the fix-get-block-not-exist branch October 21, 2025 13:15
Copy link
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

One minor comment about the err propagation

w.prevHash = common.Hash{}
return fmt.Errorf("parent hash mismatch, expected %s, got %s",
w.prevHash.String(), b.Parent.String())
return fmt.Errorf("%w, expected %s, got %s", ErrParentHashMismatch, b.Parent.String(), w.prevHash.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping like this probably won't work, since : %w must be the last argument as far as I recall.

You can use errors.Join(ErrParentHashMismatch, err) instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants