-
Notifications
You must be signed in to change notification settings - Fork 19
add possibility to poll without saving #225
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
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Poller
participant Worker
participant Storage
Caller->>Poller: Poll(ctx, blockNumbers)
Poller->>Poller: PollWithoutSaving(ctx, blockNumbers)
Poller->>Worker: Fetch blocks
Worker-->>Poller: Block fetch results
Poller->>Poller: convertPollResultsToBlockData(results)
Poller->>Poller: StageResults(successfulBlocks, failedResults)
Poller->>Storage: Insert successful block data
Poller->>Poller: handleBlockFailures(failedResults)
Poller-->>Caller: Return latest polled block
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c3d9b2b
to
fdf67f3
Compare
5628b1f
to
5305187
Compare
05ef01c
to
4450a45
Compare
5305187
to
6e15133
Compare
4450a45
to
ec67258
Compare
6e15133
to
3fb9870
Compare
ec67258
to
c35218d
Compare
c35218d
to
ca1698e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/orchestrator/poller.go
(2 hunks)
🔇 Additional comments (1)
internal/orchestrator/poller.go (1)
190-193
: UpdatelastPolledBlock
only after successful fetch
p.lastPolledBlock
is advanced before the worker runs.
If every RPC call in the batch fails, the poller will still skip these blocks forever.
Consider moving the assignment afterconvertPollResultsToBlockData
and only when
len(blockData) > 0
.
ca1698e
to
4139a04
Compare
TL;DR
Refactored the Poller to separate block polling from data storage operations.
What changed?
Poll
method into two separate methods:PollWithoutSaving
: Handles only the polling of blocks without storing dataStageResults
: Handles the storage of polled block dataconvertPollResultsToBlockData
to transform poll results into block dataHow to test?
PollWithoutSaving
method by calling it directly and verifying it returns the correct block data without savingStageResults
method by passing block data and verifying it's properly storedPoll
method still returns the highest block number correctlyWhy make this change?
This refactoring improves the separation of concerns in the Poller, making it more flexible by allowing clients to poll blocks without immediately saving the data. This enables more advanced use cases where data processing might be needed before storage, and makes the code more maintainable by breaking down the monolithic polling function into smaller, more focused components.
Summary by CodeRabbit