-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
refactor: pull libbitcoin_server (governance) code out of wallet code 4/N #5762
Conversation
58b517d
to
41a76d8
Compare
This pull request has conflicts, please rebase. |
41a76d8
to
15a1fb9
Compare
src/util/governance.h
Outdated
|
||
namespace Governance | ||
{ | ||
struct Object |
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.
this should be a class; while basically the same; we should stick to structs simply store some values; while classes also have methods and are generally more complex
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.
agree, here's no complex logic but still 2 constructors and several helpers
src/util/governance.cpp
Outdated
@@ -0,0 +1,73 @@ | |||
// Copyright (c) 2014-2023 The Dash Core developers |
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.
why is this in the util/ folder?
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.
moved to governance/common.h
src/util/governance.h
Outdated
type{GovernanceObject::UNKNOWN}, | ||
hashParent{}, | ||
revision{0}, | ||
time{0}, | ||
collateralHash{}, | ||
vchData{} |
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.
this constructor should be replaced with a =default and then place all of these default values on the actual variables for example int64_t time{0};
for (auto it = vecObjects.begin() + std::max<int>(0, vecObjects.size() - nCount); it != vecObjects.end(); ++it) { | ||
jsonArray.push_back((*it)->ToJson()); |
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.
changed from reverse iterators to non-reverse?
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.
it's changed to reverse because std::sort is changed also order of sorting from A > B
to A < B
15a1fb9
to
e352e21
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.
utACK for either squash or merge via merge commit
I'd prefer this one get merged as merge-commit - changes all related to governance, but not are same |
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.
utACK
e352e21
to
b2ad530
Compare
Issue being fixed or feature implemented
Wallet library should not depends on server code (libbitcoin_server).
Untie this library will help to finish backport bitcoin#15639 and will unblock multiprocess: bitcoin#18677
Prior work:
What was done?
The class
CGovernanceObject
is doing too many things and doesn't have any public interface that can be used outside of governance module. This PR move publicly used functionality ofCGovernanceObject
to a new simpleGovernance::Object
that can be used outside of governance module as a public interface for serialization/deserialization and can be used inside wallet.As side effect have been removed 2 circular dependency:
How Has This Been Tested?
Amount of linkage errors is decreased from 141 to 66 if libbitcoin_server is excluded during linkage:
Breaking Changes
N/A
Checklist: