mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
Merge #17474: Bugfix: GUI: Recognise NETWORK_LIMITED in formatServicesStr
4341bffb6e
GUI: Refactor formatServicesStr to warn when a ServicesFlag is missing (Luke Dashjr)df77de8c21
Bugfix: GUI: Recognise NETWORK_LIMITED in formatServicesStr (Luke Dashjr) Pull request description: Currently, only the bottom 8 service bits are shown in the GUI peer details view. `NODE_NETWORK_LIMITED` is the 11th bit (2^10). The first commit expands the range to cover the full 64 bits, and properly label `"NETWORK_LIMITED"`. The second commit refactors the code so that any future omitted service bits will trigger a compile warning. ACKs for top commit: jonasschnelli: utACK4341bffb6e
jonasschnelli: Tested ACK4341bffb6e
hebasto: Concept ACK4341bffb6e
Tree-SHA512: 8338737d03fbcd92024159aabd7e632d46e13c72436d935b504d2bf7ee92b7d124e89a5917bf64d51c87f12a64de703270c2d7b4c6711fa8ed08ea7887d817c7
This commit is contained in:
commit
5948398b18
2 changed files with 22 additions and 20 deletions
|
@ -237,6 +237,7 @@ const std::vector<std::string> &getAllNetMessageTypes();
|
|||
|
||||
/** nServices flags */
|
||||
enum ServiceFlags : uint64_t {
|
||||
// NOTE: When adding here, be sure to update qt/guiutil.cpp's formatServicesStr too
|
||||
// Nothing
|
||||
NODE_NONE = 0,
|
||||
// NODE_NETWORK means that the node is capable of serving the complete block chain. It is currently
|
||||
|
|
|
@ -731,32 +731,33 @@ QString formatDurationStr(int secs)
|
|||
return strList.join(" ");
|
||||
}
|
||||
|
||||
QString serviceFlagToStr(const quint64 mask, const int bit)
|
||||
{
|
||||
switch (ServiceFlags(mask)) {
|
||||
case NODE_NONE: abort(); // impossible
|
||||
case NODE_NETWORK: return "NETWORK";
|
||||
case NODE_GETUTXO: return "GETUTXO";
|
||||
case NODE_BLOOM: return "BLOOM";
|
||||
case NODE_WITNESS: return "WITNESS";
|
||||
case NODE_NETWORK_LIMITED: return "NETWORK_LIMITED";
|
||||
// Not using default, so we get warned when a case is missing
|
||||
}
|
||||
if (bit < 8) {
|
||||
return QString("%1[%2]").arg("UNKNOWN").arg(mask);
|
||||
} else {
|
||||
return QString("%1[2^%2]").arg("UNKNOWN").arg(bit);
|
||||
}
|
||||
}
|
||||
|
||||
QString formatServicesStr(quint64 mask)
|
||||
{
|
||||
QStringList strList;
|
||||
|
||||
// Just scan the last 8 bits for now.
|
||||
for (int i = 0; i < 8; i++) {
|
||||
uint64_t check = 1 << i;
|
||||
for (int i = 0; i < 64; i++) {
|
||||
uint64_t check = 1LL << i;
|
||||
if (mask & check)
|
||||
{
|
||||
switch (check)
|
||||
{
|
||||
case NODE_NETWORK:
|
||||
strList.append("NETWORK");
|
||||
break;
|
||||
case NODE_GETUTXO:
|
||||
strList.append("GETUTXO");
|
||||
break;
|
||||
case NODE_BLOOM:
|
||||
strList.append("BLOOM");
|
||||
break;
|
||||
case NODE_WITNESS:
|
||||
strList.append("WITNESS");
|
||||
break;
|
||||
default:
|
||||
strList.append(QString("%1[%2]").arg("UNKNOWN").arg(check));
|
||||
}
|
||||
strList.append(serviceFlagToStr(check, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue