-
Notifications
You must be signed in to change notification settings - Fork 292
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
netsync: Split blockmanager into separate package. #2500
Conversation
ba524ab
to
9f2fca3
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.
Tested all commits with run_tests.go
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.
Should be good to go after a rebase.
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.
Looks great. The new code is definitely clearer in terms of what SyncManager
handles.
One small note, I noticed that there are still a few leftover comments referencing blockManager
in internal/netsync/manager.go
and some comments in server.go
referring to blockmanager
as well.
9f2fca3
to
8e0265d
Compare
This renames the field that houses the block manager to syncManager to more accurately reflect its purpose and updates comments accordingly. This is part of an overall effort to split the block manager out into a separate internal netsync package.
This renames the block manager logging subsystem from BMGR to SYNC and updates all related documentation accordingly. This is part of an overall effort to split the block manager out into a separate internal netsync package.
This adds a temporary sync manager interface to facilitate cleaner diffs when moving the block manager to a new package. This is part of an overall effort to split the block manager out into a separate internal netsync package.
This does the minimum work necessary to refactor the block manager into its own internal package named netsync. The main motivation is that separating this code into its own package will improve its testability and more cleanly split the details related to syncing with the network from consensus validation. The API will certainly need some additional cleanup and changes to make it more usable outside of the specific circumstances it currently supports, however it is better to do that in future commits in order to keep the changeset as small as possible during this refactor. Overview of the major changes: - Create the new package - Move blockmanager.go -> internal/netsync/manager.go - Update logging to use the new netsync package logger - Rename blockManagerConfig to Config (now netsync.Config) - Move peerNotifier to netsync/interface.go (now netsync.PeerNotifier) - Move syncManager to netsync/interface.go (now netsync.SyncManager) - Rename newBlockManager to New (now netsync.New) - Update all references to the block manager to use the package - Add package logger - Initialize new package logger with sync logger
This removes the temporary netsync.SyncManager interface that was added to facilitate refactoring the block manager to the new netsync package and renames the blockManager struct to SyncManager so it is exported. It also updates callers to use the concrete struct versus the removed interface.
8e0265d
to
e7a3670
Compare
@rstaudt2 Thanks for pointing out the missed comments. Looks like I missed some in the shuffle when breaking this all up into more easily digestible commits for review. I've modified the respective commits to update all of the relevant comments and log messages. Note that I did not modify any |
This requires #2498 and #2499.
This does the minimum work necessary to refactor the block manager into its own internal package named
netsync
. The main motivation is that separating this code into its own package will improve its testability and more cleanly split the details related to syncing with the network from consensus validation.The API will certainly need some additional cleanup and changes to make it more usable outside of the specific circumstances it currently supports, however it is better to do that in future commits in order to keep the changeset as small as possible during this refactor.
It has been carefully crafted into a series of individual commits that make each step easier to review as it would be a giant blob of changes that would be very hard to review otherwise. As a case in point, a temporary interface is introduced and then removed later to allow renaming to happen in a separate commit while ensuring every individual commit continues to build and work properly along the way.
Overview of the major changes:
blockManager
field tosyncManager
BMGR
logging subsystem toSYNC
netsync
packageSYNC
subsystem loggerblockmanager.go
->internal/netsync/manager.go
blockManagerConfig
toConfig
(nownetsync.Config
)peerNotifier
tonetsync/interface.go
(nownetsync.PeerNotifier
)newBlockManager
toNew
(nownetsync.New
)blockManager
toSyncManager
(nownetsync.SyncManager
)README.md
doc.go
This is work towards #1145.