Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Echo code parameter on suspend(code) return, define LOGA(). #399

Merged
merged 2 commits into from
May 10, 2024
Merged
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
5 changes: 5 additions & 0 deletions include/bitcoin/network/define.hpp
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@
#if !defined(NDEBUG)
#define WITH_LOGO
#endif
#define WITH_LOGA
#define WITH_LOGN
#define WITH_LOGS
#define WITH_LOGP
@@ -67,6 +68,10 @@
#define HAVE_LOGO
#endif

#if defined(WITH_LOGA)
#define HAVE_LOGA
#endif

/// News (general progression).
#if defined(WITH_LOGN)
#define HAVE_LOGN
10 changes: 8 additions & 2 deletions include/bitcoin/network/log/levels.hpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,6 @@ enum : uint8_t
};

#if defined(HAVE_LOGGING)
constexpr auto application_defined = true;
#define LOG_ONLY(name) name
#define LOG(level_, message) \
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) \
@@ -53,7 +52,6 @@ enum : uint8_t
log.write(network::levels::application) << name \
<< network::levels::level_ << std::endl;
#else
constexpr auto application_defined = false;
#define LOG_ONLY(name)
#define LOG(level, message)
#define LOG_LOG(level_, message)
@@ -70,6 +68,14 @@ enum : uint8_t
#define LOGO(message)
#endif

#if defined(HAVE_LOGA)
constexpr auto application_defined = true;
#define LOGA(message) LOG(application, message)
#else
#define LOGA(message)
constexpr auto application_defined = false;
#endif

#if defined(HAVE_LOGN)
constexpr auto news_defined = true;
#define LOGN(message) LOG(news, message)
4 changes: 2 additions & 2 deletions include/bitcoin/network/p2p.hpp
Original file line number Diff line number Diff line change
@@ -115,8 +115,8 @@ class BCT_API p2p
/// Nework connections are suspended (incoming and/or outgoing).
virtual bool suspended() const NOEXCEPT;

/// Suspend/resume all connections.
virtual void suspend(const code& ec) NOEXCEPT;
/// Suspend/resume all connections (echos input parameter).
virtual code suspend(const code& ec) NOEXCEPT;
virtual void resume() NOEXCEPT;

/// Properties.
3 changes: 2 additions & 1 deletion src/p2p.cpp
Original file line number Diff line number Diff line change
@@ -412,10 +412,11 @@ void p2p::resume_connectors() NOEXCEPT
connect_suspended_.store(false);
}

void p2p::suspend(const code&) NOEXCEPT
code p2p::suspend(const code& ec) NOEXCEPT
{
suspend_acceptors();
suspend_connectors();
return ec;
}

void p2p::resume() NOEXCEPT
Loading