Skip to content

Commit

Permalink
Merge #20033: refactor: minor whitespace fixups, s/const/constexpr/ a…
Browse files Browse the repository at this point in the history
…nd remove template (followup to #19845)

89836a8 style: minor improvements as a followup to #19845 (Vasil Dimov)

Pull request description:

  Address suggestions:
  bitcoin/bitcoin#19845 (comment)
  bitcoin/bitcoin#19845 (comment)
  bitcoin/bitcoin#19845 (comment)

ACKs for top commit:
  jonatack:
    re-ACK 89836a8 change since previous review is replacing std::runtime_error with std::exception, built/ran unit tests with gcc debian 10.2.0-15, then broke a few v3 net_tests involving `BOOST_CHECK_EXCEPTION`, rebuilt, ran `src/test/test_bitcoin -t net_tests -l all` and checked the error reporting.
  hebasto:
    re-ACK 89836a8
  theStack:
    ACK 89836a8

Tree-SHA512: 36477fdccabe5a8ad91fbabb4655cc363a3a7ca237a98ae6dd4a9fae4a4113762040f864d4ca13a47d081f7d16e5bd487edbfb61ab50a37e4a0424e9bec30b24
  • Loading branch information
MarcoFalke committed Nov 16, 2020
2 parents 0ede354 + 89836a8 commit 2fa085a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/netaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* Make sure that this does not collide with any of the values in `version.h`
* or with `SERIALIZE_TRANSACTION_NO_WITNESS`.
*/
static const int ADDRV2_FORMAT = 0x20000000;
static constexpr int ADDRV2_FORMAT = 0x20000000;

/**
* A network type.
Expand Down
9 changes: 6 additions & 3 deletions src/test/util/setup_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <node/context.h>
#include <pubkey.h>
#include <random.h>
#include <stdexcept>
#include <txmempool.h>
#include <util/check.h>
#include <util/string.h>
Expand Down Expand Up @@ -158,13 +159,15 @@ std::ostream& operator<<(std::ostream& os, const uint256& num);
* Use as
* BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo"));
*/
class HasReason {
class HasReason
{
public:
explicit HasReason(const std::string& reason) : m_reason(reason) {}
template <typename E>
bool operator() (const E& e) const {
bool operator()(const std::exception& e) const
{
return std::string(e.what()).find(m_reason) != std::string::npos;
};

private:
const std::string m_reason;
};
Expand Down

0 comments on commit 2fa085a

Please sign in to comment.