refactor: move all network operations out of CGovernanceManager#7106
Conversation
…thods Replace SyncObjects() and SyncSingleObjVotes() with pure data accessors: - GetSyncableObjectInvs(): returns inventory of syncable governance objects - GetSyncableVoteInvs(): returns inventory of syncable votes for an object Move network message construction (SYNCSTATUSCOUNT) to NetGovernance, following the established pattern in NetSigning and NetInstantSend. This improves separation of concerns: - CGovernanceManager handles data access only - NetGovernance handles network protocol operations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Complete separation of network operations from CGovernanceManager by moving RequestGovernanceObject functionality to the appropriate network layer classes. Changes to CGovernanceManager (data access only): - Add GetVoteBloomFilter() to build bloom filter for sync requests - Add GetOrphanVoteObjectHashes() to get object hashes for orphan votes - Modify ProcessVote() to use output param hashToRequest instead of doing network operations internally - Remove RequestGovernanceObject() and RequestOrphanObjects() Changes to SyncManager: - Add SendGovernanceObjectSyncRequest() for vote sync requests - Update RequestGovernanceObjectVotes() to use new method Changes to NetGovernance: - Handle orphan vote requests in ProcessMessage() after ProcessVote - Move RequestOrphanObjects logic into Schedule() for periodic requests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughThe changes decouple governance data collection from network I/O by replacing several network-performing methods with pure getters: SyncObjects → GetSyncableObjectInvs, SyncSingleObjVotes → GetSyncableVoteInvs, RequestGovernanceObject → GetVoteBloomFilter, and RequestOrphanObjects → GetOrphanVoteObjectHashes. ProcessVote now returns an output Sequence Diagram(s)sequenceDiagram
participant SyncMgr as SyncManager
participant GovMgr as CGovernanceManager
participant Connman as CConnman/Peers
SyncMgr->>GovMgr: GetSyncableObjectInvs()
GovMgr-->>SyncMgr: vector<CInv> (objects)
SyncMgr->>Connman: Send SYNCSTATUSCOUNT (GOVOBJ)
SyncMgr->>Connman: Relay invs for each CInv
sequenceDiagram
participant Peer as RemotePeer
participant NetGov as NetGovernance
participant GovMgr as CGovernanceManager
participant SyncMgr as SyncManager
participant Connman as CConnman/Peers
Peer->>NetGov: MNGOVERNANCEOBJECTVOTE (vote)
NetGov->>GovMgr: ProcessVote(peer, vote, exception, hashToRequest)
GovMgr-->>NetGov: bool accepted, hashToRequest (maybe zero)
alt vote rejected && hashToRequest != 0
NetGov->>SyncMgr: SendGovernanceObjectSyncRequest(peer, hashToRequest, useFilter=true)
SyncMgr->>Connman: Push MNGOVERNANCESYNC (hashToRequest, bloom filter)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
knst
left a comment
There was a problem hiding this comment.
LGTM overall, consider further improvements (2 commits attached to my comments); nits are minor
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
|
ping @PastaPastaPasta |
Issue being fixed or feature implemented
Move all network operations from
CGovernanceManagerto the appropriate network layer classes (SyncManagerandNetGovernance).What was done?
Refactor only, see individual commits
How Has This Been Tested?
Run tests, sync gov data on mainnet node
Breaking Changes
n/a
Checklist: