-
Notifications
You must be signed in to change notification settings - Fork 245
refactor: make sync service generic #1721
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
|
Warning Rate limit exceeded@tzdybal has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 45 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes span multiple files to implement a P2P Sync Service leveraging Go generics to consolidate HeaderSync and BlockSync functionalities. These adjustments simplify storage access methods and synchronize headers and blocks more efficiently in the Changes
Sequence Diagram(s)sequenceDiagram
participant Node as Node
participant SyncService as SyncService
participant Network as Network
Node->>SyncService: Initialize SyncService
SyncService->>Network: Broadcast headers/blocks
Network-->>SyncService: Receive headers/blocks
SyncService->>Node: Store received headers/blocks
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Manav-Aggarwal
left a comment
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.
some nits, otherwise LGTM
|
I think it's okay, time to move on and use new features |
gupadhyaya
left a comment
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.
overall looks awesome. thanks
27cc650 to
77f108d
Compare
|
How does this PR relate to #1501 ? |
b3b58e6 to
be58c09
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: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- block/sync_service.go (1 hunks)
- node/full.go (3 hunks)
- node/full_node_integration_test.go (1 hunks)
- node/helpers.go (1 hunks)
- types/block.go (1 hunks)
Additional comments not posted (8)
node/helpers.go (2)
76-79: Use of newStore()method ingetNodeHeightFromHeaderis appropriate.This change correctly reflects the consolidation of the
HeaderStore()andBlockStore()into a singleStore()method, simplifying the interface as intended by the PR.
86-86: RefactoredgetNodeHeightFromBlockto use newStore()method.This adjustment aligns with the PR's objective to unify the handling of synchronization services through a generic interface.
types/block.go (1)
144-144: UpdatedChainID()to directly return the chain ID.The change simplifies the method by removing the concatenation of
"-block", which aligns with the PR's goal to simplify and clarify the codebase. The previous concern about this change is addressed by the fact that the method now accurately reflects the actual chain ID without modification.block/sync_service.go (2)
39-54: Refactoring ofSyncServiceto use Go generics.The introduction of Go generics in the
SyncServiceclass allows for more flexible and reusable code. This change supports different types of headers or blocks, aligning with the PR's objectives to consolidate and simplify the synchronization services.
106-109: MethodStore()correctly implemented inSyncService.This method provides a unified way to access the store regardless of the specific type of sync service, which enhances modularity and code reuse.
node/full.go (2)
307-307: Correct integration ofHeaderSyncServiceinheaderPublishLoop.The method
headerPublishLoopnow correctly uses theWriteToStoreAndBroadcastmethod from theHeaderSyncService, ensuring that headers are properly managed and broadcasted.
323-323: Proper use ofBlockSyncServiceinblockPublishLoop.The
blockPublishLoopeffectively utilizes theWriteToStoreAndBroadcastmethod from theBlockSyncService, which is consistent with the PR's objectives to integrate the new generic sync services.node/full_node_integration_test.go (1)
774-774: Refactored method usage approved.The change from
node1.hSyncService.HeaderStore().GetByHeight(height)tonode1.hSyncService.Store().GetByHeight(height)aligns with the PR's goal to simplify method calls using Go generics. Ensure that the newStore()method encapsulates all functionalities of the oldHeaderStore()method correctly.
be58c09 to
f599479
Compare
Manav-Aggarwal
left a comment
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.
LGTM
Overview
Closes #1722
Summary by CodeRabbit
New Features
Improvements