-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: section off masternode network information to MnNetInfo, lay some groundwork for managing multiple entries
#6627
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
Changes from all commits
2c6dd05
aaabc35
e868aff
e1783cb
bac4a27
03ec604
2e9bde0
ecc9368
bcb8a7d
1d52678
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -394,13 +394,17 @@ class CDeterministicMNList | |
| template <typename T> | ||
| [[nodiscard]] uint256 GetUniquePropertyHash(const T& v) const | ||
| { | ||
| static_assert(!std::is_same<T, CBLSPublicKey>(), "GetUniquePropertyHash cannot be templated against CBLSPublicKey"); | ||
| #define DMNL_NO_TEMPLATE(name) \ | ||
| static_assert(!std::is_same_v<std::decay_t<T>, name>, "GetUniquePropertyHash cannot be templated against " #name) | ||
| DMNL_NO_TEMPLATE(CBLSPublicKey); | ||
| DMNL_NO_TEMPLATE(MnNetInfo); | ||
| #undef DMNL_NO_TEMPLATE | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I'd personally prefer copy-paste here rather than using
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocklist expands in later PRs (see below, WIP code) and would also include |
||
| return ::SerializeHash(v); | ||
| } | ||
| template <typename T> | ||
| [[nodiscard]] bool AddUniqueProperty(const CDeterministicMN& dmn, const T& v) | ||
| { | ||
| static const T nullValue; | ||
| static const T nullValue{}; | ||
| if (v == nullValue) { | ||
| return false; | ||
| } | ||
|
|
@@ -420,7 +424,7 @@ class CDeterministicMNList | |
| template <typename T> | ||
| [[nodiscard]] bool DeleteUniqueProperty(const CDeterministicMN& dmn, const T& oldValue) | ||
| { | ||
| static const T nullValue; | ||
| static const T nullValue{}; | ||
| if (oldValue == nullValue) { | ||
| return false; | ||
| } | ||
|
|
@@ -443,7 +447,7 @@ class CDeterministicMNList | |
| if (oldValue == newValue) { | ||
| return true; | ||
| } | ||
| static const T nullValue; | ||
| static const T nullValue{}; | ||
|
|
||
| if (oldValue != nullValue && !DeleteUniqueProperty(dmn, oldValue)) { | ||
| return false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,19 +27,19 @@ std::string CDeterministicMNState::ToString() const | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return strprintf("CDeterministicMNState(nVersion=%d, nRegisteredHeight=%d, nLastPaidHeight=%d, nPoSePenalty=%d, " | ||||||||||||||||||||||||||||
| "nPoSeRevivedHeight=%d, nPoSeBanHeight=%d, nRevocationReason=%d, " | ||||||||||||||||||||||||||||
| "ownerAddress=%s, pubKeyOperator=%s, votingAddress=%s, addr=%s, payoutAddress=%s, " | ||||||||||||||||||||||||||||
| "operatorPayoutAddress=%s)", | ||||||||||||||||||||||||||||
| "ownerAddress=%s, pubKeyOperator=%s, votingAddress=%s, payoutAddress=%s, " | ||||||||||||||||||||||||||||
| "operatorPayoutAddress=%s)\n" | ||||||||||||||||||||||||||||
| " %s", | ||||||||||||||||||||||||||||
| nVersion, nRegisteredHeight, nLastPaidHeight, nPoSePenalty, nPoSeRevivedHeight, nPoSeBanHeight, | ||||||||||||||||||||||||||||
| nRevocationReason, EncodeDestination(PKHash(keyIDOwner)), pubKeyOperator.ToString(), | ||||||||||||||||||||||||||||
| EncodeDestination(PKHash(keyIDVoting)), addr.ToStringAddrPort(), payoutAddress, | ||||||||||||||||||||||||||||
| operatorPayoutAddress); | ||||||||||||||||||||||||||||
| EncodeDestination(PKHash(keyIDVoting)), payoutAddress, operatorPayoutAddress, netInfo.ToString()); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| UniValue CDeterministicMNState::ToJson(MnType nType) const | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| UniValue obj(UniValue::VOBJ); | ||||||||||||||||||||||||||||
| obj.pushKV("version", nVersion); | ||||||||||||||||||||||||||||
| obj.pushKV("service", addr.ToStringAddrPort()); | ||||||||||||||||||||||||||||
| obj.pushKV("service", netInfo.GetPrimary().ToStringAddrPort()); | ||||||||||||||||||||||||||||
| obj.pushKV("registeredHeight", nRegisteredHeight); | ||||||||||||||||||||||||||||
| obj.pushKV("lastPaidHeight", nLastPaidHeight); | ||||||||||||||||||||||||||||
|
Comment on lines
40
to
44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
- obj.pushKV("service", netInfo.GetPrimary().ToStringAddrPort());
+ obj.pushKV("service",
+ netInfo.HasEntries() ? netInfo.GetPrimary().ToStringAddrPort()
+ : "unknown");📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||
| obj.pushKV("consecutivePayments", nConsecutivePayments); | ||||||||||||||||||||||||||||
|
|
@@ -72,8 +72,8 @@ UniValue CDeterministicMNStateDiff::ToJson(MnType nType) const | |||||||||||||||||||||||||||
| if (fields & Field_nVersion) { | ||||||||||||||||||||||||||||
| obj.pushKV("version", state.nVersion); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if (fields & Field_addr) { | ||||||||||||||||||||||||||||
| obj.pushKV("service", state.addr.ToStringAddrPort()); | ||||||||||||||||||||||||||||
| if (fields & Field_netInfo) { | ||||||||||||||||||||||||||||
| obj.pushKV("service", state.netInfo.GetPrimary().ToStringAddrPort()); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if (fields & Field_nRegisteredHeight) { | ||||||||||||||||||||||||||||
| obj.pushKV("registeredHeight", state.nRegisteredHeight); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.