mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
scripted-diff: rename NetPermissionFlags enumerators
- drop redundant PF_ permission flags prefixes - drop ALL_CAPS naming per https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps - rename IsImplicit to Implicit -BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'PF_NONE' 'None' s 'PF_BLOOMFILTER' 'BloomFilter' s 'PF_RELAY' 'Relay' s 'PF_FORCERELAY' 'ForceRelay' s 'PF_DOWNLOAD' 'Download' s 'PF_NOBAN' 'NoBan' s 'PF_MEMPOOL' 'Mempool' s 'PF_ADDR' 'Addr' s 'PF_ISIMPLICIT' 'Implicit' s 'PF_ALL' 'All' -END VERIFY SCRIPT-
This commit is contained in:
@@ -23,12 +23,12 @@ namespace {
|
||||
// The parse the following format "perm1,perm2@xxxxxx"
|
||||
bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output, size_t& readen, bilingual_str& error)
|
||||
{
|
||||
NetPermissionFlags flags = NetPermissionFlags::PF_NONE;
|
||||
NetPermissionFlags flags = NetPermissionFlags::None;
|
||||
const auto atSeparator = str.find('@');
|
||||
|
||||
// if '@' is not found (ie, "xxxxx"), the caller should apply implicit permissions
|
||||
if (atSeparator == std::string::npos) {
|
||||
NetPermissions::AddFlag(flags, NetPermissionFlags::PF_ISIMPLICIT);
|
||||
NetPermissions::AddFlag(flags, NetPermissionFlags::Implicit);
|
||||
readen = 0;
|
||||
}
|
||||
// else (ie, "perm1,perm2@xxxxx"), let's enumerate the permissions by splitting by ',' and calculate the flags
|
||||
@@ -44,14 +44,14 @@ bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output,
|
||||
readen += len; // We read "perm1"
|
||||
if (commaSeparator != std::string::npos) readen++; // We read ","
|
||||
|
||||
if (permission == "bloomfilter" || permission == "bloom") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_BLOOMFILTER);
|
||||
else if (permission == "noban") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_NOBAN);
|
||||
else if (permission == "forcerelay") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_FORCERELAY);
|
||||
else if (permission == "mempool") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_MEMPOOL);
|
||||
else if (permission == "download") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_DOWNLOAD);
|
||||
else if (permission == "all") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_ALL);
|
||||
else if (permission == "relay") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_RELAY);
|
||||
else if (permission == "addr") NetPermissions::AddFlag(flags, NetPermissionFlags::PF_ADDR);
|
||||
if (permission == "bloomfilter" || permission == "bloom") NetPermissions::AddFlag(flags, NetPermissionFlags::BloomFilter);
|
||||
else if (permission == "noban") NetPermissions::AddFlag(flags, NetPermissionFlags::NoBan);
|
||||
else if (permission == "forcerelay") NetPermissions::AddFlag(flags, NetPermissionFlags::ForceRelay);
|
||||
else if (permission == "mempool") NetPermissions::AddFlag(flags, NetPermissionFlags::Mempool);
|
||||
else if (permission == "download") NetPermissions::AddFlag(flags, NetPermissionFlags::Download);
|
||||
else if (permission == "all") NetPermissions::AddFlag(flags, NetPermissionFlags::All);
|
||||
else if (permission == "relay") NetPermissions::AddFlag(flags, NetPermissionFlags::Relay);
|
||||
else if (permission == "addr") NetPermissions::AddFlag(flags, NetPermissionFlags::Addr);
|
||||
else if (permission.length() == 0); // Allow empty entries
|
||||
else {
|
||||
error = strprintf(_("Invalid P2P permission: '%s'"), permission);
|
||||
@@ -71,13 +71,13 @@ bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output,
|
||||
std::vector<std::string> NetPermissions::ToStrings(NetPermissionFlags flags)
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_BLOOMFILTER)) strings.push_back("bloomfilter");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_NOBAN)) strings.push_back("noban");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_FORCERELAY)) strings.push_back("forcerelay");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_RELAY)) strings.push_back("relay");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_MEMPOOL)) strings.push_back("mempool");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_DOWNLOAD)) strings.push_back("download");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::PF_ADDR)) strings.push_back("addr");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::BloomFilter)) strings.push_back("bloomfilter");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::NoBan)) strings.push_back("noban");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::ForceRelay)) strings.push_back("forcerelay");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Relay)) strings.push_back("relay");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Mempool)) strings.push_back("mempool");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Download)) strings.push_back("download");
|
||||
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Addr)) strings.push_back("addr");
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user