Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Dec 8, 2020
1 parent 597f233 commit d571721
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion storage/modules/block_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ func (b *BlockStorage) SeeBlock(
ctx context.Context,
block *types.Block,
) error {
transaction := b.db.WriteTransaction(ctx, block.BlockIdentifier.Hash, true)
_, key := getBlockHashKey(block.BlockIdentifier.Hash)
transaction := b.db.WriteTransaction(ctx, string(key), true)
defer transaction.Discard(ctx)

// Store all transactions in order and check for duplicates
Expand Down
9 changes: 8 additions & 1 deletion syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,14 @@ func (s *Syncer) syncRange(
s.concurrency = startingConcurrency
s.goalConcurrency = s.concurrency

// Spawn syncing goroutines
// We create a separate derivative context here instead of
// replacing the provided ctx because the context returned
// by errgroup.WithContext is canceled as soon as Wait returns.
// If this canceled context is passed to a handler or helper,
// it can have unintended consequences (some functions
// return immediately if the context is canceled).
//
// Source: https://godoc.org/golang.org/x/sync/errgroup
g, pipelineCtx := errgroup.WithContext(ctx)
g.Go(func() error {
return s.addBlockIndices(pipelineCtx, blockIndices, s.nextIndex, endIndex)
Expand Down

0 comments on commit d571721

Please sign in to comment.