mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-27 17:31:40 +02:00
Merge #17474: Bugfix: GUI: Recognise NETWORK_LIMITED in formatServicesStr
4341bffb6ef10909f3721329db27c5dc9bc720dd GUI: Refactor formatServicesStr to warn when a ServicesFlag is missing (Luke Dashjr) df77de8c2157fbb4c0898586dacb2215286745c8 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: utACK 4341bffb6ef10909f3721329db27c5dc9bc720dd jonasschnelli: Tested ACK 4341bffb6ef10909f3721329db27c5dc9bc720dd hebasto: Concept ACK 4341bffb6ef10909f3721329db27c5dc9bc720dd Tree-SHA512: 8338737d03fbcd92024159aabd7e632d46e13c72436d935b504d2bf7ee92b7d124e89a5917bf64d51c87f12a64de703270c2d7b4c6711fa8ed08ea7887d817c7
This commit is contained in:
commit
5948398b18
@ -237,6 +237,7 @@ const std::vector<std::string> &getAllNetMessageTypes();
|
|||||||
|
|
||||||
/** nServices flags */
|
/** nServices flags */
|
||||||
enum ServiceFlags : uint64_t {
|
enum ServiceFlags : uint64_t {
|
||||||
|
// NOTE: When adding here, be sure to update qt/guiutil.cpp's formatServicesStr too
|
||||||
// Nothing
|
// Nothing
|
||||||
NODE_NONE = 0,
|
NODE_NONE = 0,
|
||||||
// NODE_NETWORK means that the node is capable of serving the complete block chain. It is currently
|
// 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(" ");
|
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)
|
QString formatServicesStr(quint64 mask)
|
||||||
{
|
{
|
||||||
QStringList strList;
|
QStringList strList;
|
||||||
|
|
||||||
// Just scan the last 8 bits for now.
|
for (int i = 0; i < 64; i++) {
|
||||||
for (int i = 0; i < 8; i++) {
|
uint64_t check = 1LL << i;
|
||||||
uint64_t check = 1 << i;
|
|
||||||
if (mask & check)
|
if (mask & check)
|
||||||
{
|
{
|
||||||
switch (check)
|
strList.append(serviceFlagToStr(check, i));
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user