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 9aca901
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion statefulsyncer/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func WithPruneSleepTime(sleepTime int) Option {
}

// WithSeenConcurrency overrides the number of concurrent
// invocations of BlockSeen we will make. We default
// invocations of BlockSeen we will handle. We default
// to the value of runtime.NumCPU().
func WithSeenConcurrency(concurrency int64) Option {
return func(s *StatefulSyncer) {
Expand Down
5 changes: 2 additions & 3 deletions statefulsyncer/stateful_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ type StatefulSyncer struct {
adjustmentWindow int64
pruneSleepTime time.Duration

// SeenSemaphore controls how many concurrent
// invocations we make to the SeenBlock function
// in the handler.
// SeenSemaphore limits how many executions of
// BlockSeen occur concurrently.
seenSemaphore *semaphore.Weighted
seenSemaphoreSize int64
}
Expand Down
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 9aca901

Please sign in to comment.