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

Support Omitted Blocks #98

Merged
merged 4 commits into from
Aug 10, 2020
Merged

Support Omitted Blocks #98

merged 4 commits into from
Aug 10, 2020

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Aug 8, 2020

Blocked by: coinbase/mesh-sdk-go#91

This PR adds support for storing omitted blocks and for querying blocks by only index or only hash (previously had to provide both block hash and index).

Warning

This PR changes how data is persisted to storage. When you upgrade, you will need to delete any cache you were using previously.

Changes

@patrick-ogrady patrick-ogrady changed the title [WIP] Add tests for omitted blocks to block storage Support Omitted Blocks Aug 8, 2020
@coveralls
Copy link

coveralls commented Aug 8, 2020

Pull Request Test Coverage Report for Build 3382

  • 58 of 71 (81.69%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.4%) to 71.993%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/storage/block_storage.go 58 71 81.69%
Files with Coverage Reduction New Missed Lines %
pkg/storage/block_storage.go 3 66.18%
Totals Coverage Status
Change from base Build 3360: 0.4%
Covered Lines: 1622
Relevant Lines: 2253

💛 - Coveralls

@@ -49,7 +49,7 @@ func (h *ReconcilerHelper) BlockExists(
ctx context.Context,
block *types.BlockIdentifier,
) (bool, error) {
_, err := h.blockStorage.GetBlock(ctx, block)
_, err := h.blockStorage.GetBlock(ctx, types.ConstructPartialBlockIdentifier(block))
if err == nil {
Copy link

Choose a reason for hiding this comment

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

nit: feels like it's more idiomatic to evaluate if err != nil first

        _, err := h.blockStorage.GetBlock(ctx, types.ConstructPartialBlockIdentifier(block))
	if err != nil {
		if errors.Is(err, storage.ErrBlockNotFound) {
			return false, nil
		}

		return false, err
	}

	return true, nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although I agree it is more idiomatic to do if err != nil first, I think it is more preferable to avoid nesting conditionals.

@patrick-ogrady patrick-ogrady merged commit 6bcf424 into master Aug 10, 2020
@patrick-ogrady patrick-ogrady deleted the patrick/support-block-gaps branch August 10, 2020 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants