Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,10 @@ class NetinfoRequestHandler : public BaseRequestHandler
return " signet";
case ChainType::REGTEST:
return " regtest";
default:
case ChainType::MAIN:
return "";
}
assert(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our Developer Notes also suggest a comment // no default case, so the compiler can warn about missing cases.

}
std::string PingTimeToString(double seconds) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, c
return CChainParams::RegTest(opts);
}
}
throw std::invalid_argument(strprintf("%s: Invalid ChainType value", __func__));
assert(false);
}

void SelectParams(const ChainType chain)
Expand Down
5 changes: 1 addition & 4 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class ArgsManager;

/**
* Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
* @returns a CChainParams* of the chosen chain.
* @throws a std::runtime_error if the chain is not supported.
*/
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain);

Expand All @@ -37,8 +35,7 @@ std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, c
const CChainParams &Params();

/**
* Sets the params returned by Params() to those for the given chain name.
* @throws std::runtime_error when the chain is not supported.
* Sets the params returned by Params() to those for the given chain type.
Comment thread
fanquake marked this conversation as resolved.
*/
void SelectParams(const ChainType chain);

Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain)
case ChainType::REGTEST:
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
}
throw std::invalid_argument(strprintf("%s: Invalid ChainType value", __func__));
assert(false);
}

void SelectBaseParams(const ChainType chain)
Expand Down
2 changes: 0 additions & 2 deletions src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class CBaseChainParams

/**
* Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain.
* @returns a CBaseChainParams* of the chosen chain.
* @throws a std::runtime_error if the chain is not supported.
*/
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain);

Expand Down
6 changes: 3 additions & 3 deletions src/common/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ class ArgsManager
void ForceSetArg(const std::string& strArg, const std::string& strValue);

/**
* Returns the appropriate chain name from the program arguments.
* Returns the appropriate chain type from the program arguments.
* @return ChainType::MAIN by default; raises runtime error if an invalid
* combination, or unknown chain is given.
*/
ChainType GetChainType() const;

/**
* Returns the appropriate chain name string from the program arguments.
* Returns the appropriate chain type string from the program arguments.
* @return ChainType::MAIN string by default; raises runtime error if an
* invalid combination is given.
*/
Expand Down Expand Up @@ -423,7 +423,7 @@ class ArgsManager

/**
* Return -regtest/-signet/-testnet/-chain= setting as a ChainType enum if a
* recognized chain name was set, or as a string if an unrecognized chain
* recognized chain type was set, or as a string if an unrecognized chain
* name was set. Raise an exception if an invalid combination of flags was
* provided.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/test/argsman_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(util_ParseInvalidParameters)
BOOST_CHECK(!test.ParseParameters(2, (char**)argv, error));
BOOST_CHECK_EQUAL(error, "Invalid parameter -unregistered");

// Make sure registered parameters prefixed with a chain name trigger errors.
// Make sure registered parameters prefixed with a chain type trigger errors.
// (Previously, they were accepted and ignored.)
argv[1] = "-test.registered";
BOOST_CHECK(!test.ParseParameters(2, (char**)argv, error));
Expand Down