Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaidashenko committed Jan 23, 2025
1 parent f729a34 commit 6b4c5b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion pkg/solana/logpoller/blocks_sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/services"
)

const blocksChBuffer = 16

type blocksSorter struct {
// service state management
services.Service
Expand All @@ -31,7 +33,7 @@ func newBlocksSorter(inBlocks <-chan Block, lggr logger.Logger, expectedBlocks [
queue: list.New(),
readyBlocks: make(map[uint64]Block),
inBlocks: inBlocks,
outBlocks: make(chan Block, 16),
outBlocks: make(chan Block, blocksChBuffer),
receivedNewBlock: make(chan struct{}, 1),
lggr: lggr,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/solana/logpoller/job_get_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
)

// getBlockJob is a job that fetches blocks with transactions, coverts logs into ProgramEvents and writes them into blocks channel
// getBlockJob is a job that fetches a block with transactions, converts logs into ProgramEvents and writes them into blocks channel
type getBlockJob struct {
slotNumber uint64
client RPCClient
Expand Down
8 changes: 4 additions & 4 deletions pkg/solana/logpoller/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ func (c *EncodedLogCollector) getSlotsToFetch(ctx context.Context, addresses []P

func (c *EncodedLogCollector) scheduleBlocksFetching(ctx context.Context, slots []uint64) (<-chan Block, error) {
blocks := make(chan Block)
getBlocksJobs := make([]*getBlockJob, len(slots))
getBlockJobs := make([]*getBlockJob, len(slots))
for i, slot := range slots {
getBlocksJobs[i] = newGetBlockJob(c.client, blocks, c.lggr, slot)
err := c.workers.Do(ctx, getBlocksJobs[i])
getBlockJobs[i] = newGetBlockJob(c.client, blocks, c.lggr, slot)
err := c.workers.Do(ctx, getBlockJobs[i])
if err != nil {
return nil, fmt.Errorf("could not schedule job to fetch blocks for slot: %w", err)
}
}

c.engine.Go(func(ctx context.Context) {
for _, job := range getBlocksJobs {
for _, job := range getBlockJobs {
select {
case <-ctx.Done():
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/solana/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ consumedAllBlocks:
}

batch := []Block{block}
batch = appendBuffered(blocks, 16, batch)
batch = appendBuffered(blocks, blocksChBuffer, batch)
err = lp.processBlocks(ctx, batch)
if err != nil {
return fmt.Errorf("error processing blocks: %w", err)
Expand Down

0 comments on commit 6b4c5b8

Please sign in to comment.