Skip to content

Commit

Permalink
MACRO fix + submodule changes from #1119 PR (#1978)
Browse files Browse the repository at this point in the history
* BEAM_LOG_WARNING

BEAM_LOG_UNHANDLED_EXCEPTION
BEAM_LOG_CRITICAL
BEAM_LOG_ERROR
BEAM_LOG_INFO

BEAM_LOG_MESSAGE

* try c++20

* WIP: tests refactoring

fixed atomic_swap.cpp

* (c)'ts

* README.md

* strict c++20 (this capture)

* fixed ;

* BEAM_LOG_DEBUG

* BEAM_LOG_DEBUG macro fix

* revert BEAM_LOG_DEBUG const

---------

Co-authored-by: Anatol Sevastsyan <anatol@beam-mw.com>
  • Loading branch information
Tatsujin1978 and anatolse authored Jun 10, 2024
1 parent 978af20 commit e893269
Show file tree
Hide file tree
Showing 55 changed files with 259 additions and 259 deletions.
8 changes: 4 additions & 4 deletions 3rdparty/libbitcoin/examples/electrum_get_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ namespace

bool on_recv(ErrorCode what, void* data, size_t size) {
if (data && size) {
LOG_DEBUG() << "RECEIVED " << size << " bytes";
LOG_DEBUG() << "\n" << std::string((const char*)data, size);
BEAM_LOG_DEBUG() << "RECEIVED " << size << " bytes";
BEAM_LOG_DEBUG() << "\n" << std::string((const char*)data, size);
}
else {
LOG_DEBUG() << __FUNCTION__ << " ERROR: " << error_str(what);
BEAM_LOG_DEBUG() << __FUNCTION__ << " ERROR: " << error_str(what);
}
io::Reactor::get_Current().stop();
return true;
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace
streams.emplace_back(move(newStream));
}
else {
LOG_DEBUG() << __FUNCTION__ << " ERROR: " << error_str(status);
BEAM_LOG_DEBUG() << __FUNCTION__ << " ERROR: " << error_str(status);
io::Reactor::get_Current().stop();
}
}
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/opencl-miner/clHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void clHost::startMining()
}

cl::Event::waitForEvents(events);
LOG_DEBUG() << "Miner stopped";
BEAM_LOG_DEBUG() << "Miner stopped";
}

clHost::~clHost()
Expand Down
2 changes: 1 addition & 1 deletion beam/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace
{
if (newStream)
{
LOG_DEBUG() << "Websocket proxy connected to the node";
BEAM_LOG_DEBUG() << "Websocket proxy connected to the node";
m_Stream = std::move(newStream);
m_Stream->enable_read(
[this](io::ErrorCode errorCode, void* data, size_t size) -> bool
Expand Down
6 changes: 3 additions & 3 deletions bvm/ethash_service/ethash_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,21 @@ namespace
}
}
};
LOG_DEBUG() << "Response: \n" << msg.dump();
BEAM_LOG_DEBUG() << "Response: \n" << msg.dump();
}

void ProverApi::onHandleGetProof(const JsonRpcId& id, GetProof&& data)
{
GetProof::Response res;
std::string sEpoch = std::to_string(data.epoch);
LOG_DEBUG() << "Getting proof for epoch: " << sEpoch;
BEAM_LOG_DEBUG() << "Getting proof for epoch: " << sEpoch;
res.datasetCount = beam::EthashUtils::GenerateProof(
data.epoch,
(m_DataPath + sEpoch + ".cache").c_str(),
(m_DataPath + sEpoch + ".tre5").c_str(),
(m_DataPath + "Super.tre").c_str(),
data.hvSeed, res.proof);
LOG_DEBUG() << "Got proof";
BEAM_LOG_DEBUG() << "Got proof";
doResponse(id, res);
}

Expand Down
4 changes: 2 additions & 2 deletions explorer/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void Server::on_stream_accepted(io::TcpStream::Ptr&& newStream, io::ErrorCode er
}

newStream->enable_keepalive(1);
LOG_DEBUG() << STS << "+peer " << peer;
BEAM_LOG_DEBUG() << STS << "+peer " << peer;
_connections[peer.u64()] = std::make_unique<HttpConnection>(
peer.u64(),
BaseConnection::inbound,
Expand Down Expand Up @@ -616,7 +616,7 @@ bool Server::on_request(uint64_t id, const HttpMsgReader::Message& msg)
if (it == _connections.end()) return false;

if (msg.what != HttpMsgReader::http_message || !msg.msg) {
LOG_DEBUG() << STS << "-peer " << io::Address::from_u64(id) << " : " << msg.error_str();
BEAM_LOG_DEBUG() << STS << "-peer " << io::Address::from_u64(id) << " : " << msg.error_str();
_connections.erase(id);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions http/http_msg_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct HeadersParserStuff {
}

if (result == -1) {
//LOG_DEBUG() << "Corrupted " << std::string(headers_buffer, headers_cursor + maxBytes);
//BEAM_LOG_DEBUG() << "Corrupted " << std::string(headers_buffer, headers_cursor + maxBytes);
error = HttpMsgReader::message_corrupted;
return false;
}
Expand All @@ -245,7 +245,7 @@ struct HeadersParserStuff {
error = HttpMsgReader::message_too_long;
}

//LOG_DEBUG() << "incompleted: " << std::string(headers_buffer, headers_cursor);
//BEAM_LOG_DEBUG() << "incompleted: " << std::string(headers_buffer, headers_cursor);

consumed = maxBytes;
return false;
Expand Down
12 changes: 6 additions & 6 deletions http/unittests/http_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ namespace {
request.address(a).connectTimeoutMsec(2000).pathAndQuery("/").headers(headers).numHeaders(1)
.callback(
[&expected, &nErrors](uint64_t id, const HttpMsgReader::Message& msg) -> bool {
LOG_DEBUG() << "response from " << id;
BEAM_LOG_DEBUG() << "response from " << id;
auto it = expected.find(id);
if (it == expected.end()) {
LOG_DEBUG() << "unexpected response";
BEAM_LOG_DEBUG() << "unexpected response";
++nErrors;
}
if (msg.what == HttpMsgReader::http_message) {
size_t sz=0;
const void* body = msg.msg->get_body(sz);
LOG_DEBUG() << "received " << sz << " bytes";
BEAM_LOG_DEBUG() << "received " << sz << " bytes";
if (body) {
LOG_DEBUG() << std::string_view((const char*)body, sz);
BEAM_LOG_DEBUG() << std::string_view((const char*)body, sz);
}
if (it->second != io::EC_OK || sz == 0) {
++nErrors;
}
} else {
if (it->second != msg.connectionError) {
LOG_DEBUG() << "Invalid error, expected:" << it->second << ", received: " << msg.connectionError;
BEAM_LOG_DEBUG() << "Invalid error, expected:" << it->second << ", received: " << msg.connectionError;
++nErrors;
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ int main() {
auto logger = Logger::create(logLevel, logLevel);
auto res = http_client_test(false);
res += http_client_test(true);
LOG_DEBUG() << TRACE(res);
BEAM_LOG_DEBUG() << TRACE(res);
return res;
}

6 changes: 3 additions & 3 deletions http/unittests/http_parser_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct FragmentedInput {

int report(const char* fn, int errors) {
if (errors) { BEAM_LOG_ERROR() << fn << " " << errors << " errors"; }
else { LOG_DEBUG() << fn << " ok"; }
else { BEAM_LOG_DEBUG() << fn << " ok"; }
return errors;
}
#define REPORT(errors) report(__FUNCTION__, errors)
Expand Down Expand Up @@ -159,7 +159,7 @@ int test_multiple() {
fragmentSize += 9;
}

LOG_DEBUG() << __FUNCTION__ << TRACE(calls) << TRACE(corrupted);
BEAM_LOG_DEBUG() << __FUNCTION__ << TRACE(calls) << TRACE(corrupted);

return REPORT(errors);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ int test_chunked() {
reader.new_data_from_stream(io::EC_OK, st2.data(), st2.size());
reader.new_data_from_stream(io::EC_OK, st3.data(), st3.size());

LOG_DEBUG() << __FUNCTION__ << TRACE(corrupted);
BEAM_LOG_DEBUG() << __FUNCTION__ << TRACE(corrupted);

return REPORT(errors);
}
Expand Down
12 changes: 6 additions & 6 deletions http/unittests/http_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DummyHttpServer {
private:
void on_stream_accepted(io::TcpStream::Ptr&& newStream, io::ErrorCode errorCode) {
if (errorCode == 0) {
LOG_DEBUG() << "Stream accepted";
BEAM_LOG_DEBUG() << "Stream accepted";
_theConnection = std::make_unique<HttpConnection>(
222,
BaseConnection::inbound,
Expand Down Expand Up @@ -85,7 +85,7 @@ class DummyHttpServer {
try {
body = io::map_file_read_only(path.c_str());
} catch (const std::exception& e) {
LOG_DEBUG() << e.what();
BEAM_LOG_DEBUG() << e.what();
code = 404;
message = "Not found";
}
Expand Down Expand Up @@ -242,21 +242,21 @@ int http_server_test(bool ssl) {
get_this_path();
reactor = io::Reactor::create();
io::Reactor& r = *reactor;
LOG_DEBUG() << reactor.use_count();
BEAM_LOG_DEBUG() << reactor.use_count();
io::AsyncEvent::Ptr stopEvent = io::AsyncEvent::create(r, [&r]() {r.stop();});
LOG_DEBUG() << reactor.use_count();
BEAM_LOG_DEBUG() << reactor.use_count();
g_stopEvent = stopEvent;
DummyHttpServer server(r, ssl);
DummyHttpClient client(r, ssl);
reactor->run();
nErrors = client.uncompleted;
LOG_DEBUG() << reactor.use_count();
BEAM_LOG_DEBUG() << reactor.use_count();
} catch (const std::exception& e) {
BEAM_LOG_ERROR() << e.what();
nErrors = 255;
}

LOG_DEBUG() << reactor.use_count();
BEAM_LOG_DEBUG() << reactor.use_count();
return nErrors;
}

Expand Down
2 changes: 1 addition & 1 deletion keykeeper/local_private_key_keeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ namespace beam::wallet
pc.m_Signature = x.m_PaymentProofSignature;
if (!pc.IsValid(x.m_Peer))
{
LOG_DEBUG() << "Payment proof confimation failed";
BEAM_LOG_DEBUG() << "Payment proof confimation failed";
return Status::Unspecified;
}
}
Expand Down
4 changes: 2 additions & 2 deletions node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4420,7 +4420,7 @@ void Node::Server::OnAccepted(io::TcpStream::Ptr&& newStream, int errorCode)
{
if (newStream)
{
LOG_DEBUG() << "New peer connected: " << newStream->address();
BEAM_LOG_DEBUG() << "New peer connected: " << newStream->address();
Peer* p = get_ParentObj().AllocPeer(newStream->peer_address());
p->Accept(std::move(newStream));
p->m_Flags |= Peer::Flags::Accepted;
Expand Down Expand Up @@ -4568,7 +4568,7 @@ void Node::Miner::OnRefresh(uint32_t iIdx)
}
catch (const std::exception& ex)
{
LOG_DEBUG() << ex.what();
BEAM_LOG_DEBUG() << ex.what();
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions p2p/unittest/dialog_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct NetworkSide : public IErrorHandler, public ILogicToNetwork, public AsyncC

void on_stream_accepted(io::TcpStream::Ptr&& newStream, io::ErrorCode errorCode) {
if (errorCode == 0) {
LOG_DEBUG() << "Stream accepted";
BEAM_LOG_DEBUG() << "Stream accepted";
if (!connection) {
connection = make_unique<Connection>(
protocol,
Expand Down Expand Up @@ -286,7 +286,7 @@ struct EventDrivenAppLogic : INetworkToLogic {
stop();
return;
}
LOG_DEBUG() << "sending request, x=" << ++counter;
BEAM_LOG_DEBUG() << "sending request, x=" << ++counter;
Request req;
req.x = counter;
for (int i=0, sz = 13 * counter; i<sz; ++i) req.ooo.push_back(i);
Expand Down Expand Up @@ -333,7 +333,7 @@ int main() {
try {
constexpr uint16_t port = 32123;

LOG_DEBUG() << "Creating apps";
BEAM_LOG_DEBUG() << "Creating apps";

// server
App app1(io::Address::localhost().port(port), true, 57);
Expand Down
4 changes: 2 additions & 2 deletions p2p/unittest/filesend_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ struct NetworkSide : public IErrorHandler, public ILogicToNetwork, public AsyncC

void on_stream_accepted(io::TcpStream::Ptr&& newStream, io::ErrorCode errorCode) {
if (errorCode == 0) {
LOG_DEBUG() << "Stream accepted";
BEAM_LOG_DEBUG() << "Stream accepted";
if (!connection) {
connection = make_unique<Connection>(
protocol,
Expand Down Expand Up @@ -376,7 +376,7 @@ int main() {
try {
constexpr uint16_t port = 32123;

LOG_DEBUG() << "Creating apps";
BEAM_LOG_DEBUG() << "Creating apps";

// server
App app1(io::Address::localhost().port(port), true, 345);
Expand Down
8 changes: 4 additions & 4 deletions pow/miner_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class StratumClient : public stratum::ParserCallback {

private:
bool on_raw_message(void* data, size_t size) {
LOG_DEBUG() << "got " << std::string((char*)data, size-1);
BEAM_LOG_DEBUG() << "got " << std::string((char*)data, size-1);
return stratum::parse_json_msg(data, size, *this);
}

Expand Down Expand Up @@ -101,7 +101,7 @@ class StratumClient : public stratum::ParserCallback {
if (res.code < 0) {
return on_stratum_error(res.code);
}
LOG_DEBUG() << "ignoring result message, code=" << res.code << " description=" << res.description;
BEAM_LOG_DEBUG() << "ignoring result message, code=" << res.code << " description=" << res.description;
return true;
}

Expand All @@ -115,7 +115,7 @@ class StratumClient : public stratum::ParserCallback {
}

//char buf[72];
//LOG_DEBUG() << "input=" << to_hex(buf, _lastJobInput.m_pData, 32);
//BEAM_LOG_DEBUG() << "input=" << to_hex(buf, _lastJobInput.m_pData, 32);

if (!_fakeSolver && !_lastFoundBlock.IsValid(_lastJobInput.m_pData, 32, h)) {
BEAM_LOG_ERROR() << "solution is invalid, id=" << _lastJobID;
Expand Down Expand Up @@ -165,7 +165,7 @@ class StratumClient : public stratum::ParserCallback {
_blockSent = true; //TODO ???
}
} else {
LOG_DEBUG() << "ignoring message, no connection";
BEAM_LOG_DEBUG() << "ignoring message, no connection";
}
}

Expand Down
2 changes: 1 addition & 1 deletion pow/opencl_pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace beam {
{
bool cpuMine = false;

LOG_DEBUG() << "runOpenclMiner()";
BEAM_LOG_DEBUG() << "runOpenclMiner()";



Expand Down
4 changes: 2 additions & 2 deletions pow/stratum_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void Server::refresh_acl() {
void Server::on_stream_accepted(io::TcpStream::Ptr&& newStream, io::ErrorCode errorCode) {
if (errorCode == 0) {
auto peer = newStream->peer_address();
LOG_DEBUG() << STS << "+peer " << peer;
BEAM_LOG_DEBUG() << STS << "+peer " << peer;
_connections[peer.u64()] = std::make_unique<Connection>(
*this,
peer.u64(),
Expand Down Expand Up @@ -150,7 +150,7 @@ bool Server::on_login(uint64_t from, const Login& login) {
}

bool Server::on_solution(uint64_t from, const Solution& sol) {
LOG_DEBUG() << TRACE(sol.nonce) << TRACE(sol.output);
BEAM_LOG_DEBUG() << TRACE(sol.nonce) << TRACE(sol.output);

if (_prefixDigits > 0) {
const std::string& nonceprefix = _connections[from]->get_nonceprefix();
Expand Down
6 changes: 3 additions & 3 deletions pow/unittests/stratum_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int json_creation_test() {
Result r("xxx", ResultCode(login_failed));
append_json_msg(lineProtocol, r);
io::SharedBuffer buf = io::normalize(m);
LOG_DEBUG() << to_string(buf);
BEAM_LOG_DEBUG() << to_string(buf);
Result x;
auto code = parse_json_msg(buf.data, buf.size, x);
if (code != 0) {
Expand Down Expand Up @@ -93,11 +93,11 @@ void gen_examples() {
append_json_msg(packer, res2);

io::SharedBuffer buf = io::normalize(m);
LOG_DEBUG() << to_string(buf);
BEAM_LOG_DEBUG() << to_string(buf);

LineProtocol reader(
[](void* data, size_t size) -> bool {
LOG_DEBUG() << std::string((char*)data, size);
BEAM_LOG_DEBUG() << std::string((char*)data, size);
return true;
},
[](io::SharedBuffer&& fragment) {}
Expand Down
4 changes: 2 additions & 2 deletions utility/asynccontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void AsyncContext::thread_func(AsyncContext::RunCallback&& beforeRun, AsyncConte
block_signals_in_this_thread();
attach_to_thread();
_started = true;
LOG_DEBUG() << "starting, thread=" << get_thread_id();
BEAM_LOG_DEBUG() << "starting, thread=" << get_thread_id();
try {
if (beforeRun) beforeRun();
_reactor->run();
Expand All @@ -82,7 +82,7 @@ void AsyncContext::thread_func(AsyncContext::RunCallback&& beforeRun, AsyncConte
BEAM_LOG_CRITICAL() << "Unhandled non-std exception in child thread";
assert(false && "exception in child thread");
}
LOG_DEBUG() << "exiting, thread=" << get_thread_id();
BEAM_LOG_DEBUG() << "exiting, thread=" << get_thread_id();
detach_from_thread();
}

Expand Down
2 changes: 1 addition & 1 deletion utility/io/coarsetimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static inline uint64_t mono_clock() {

Result CoarseTimer::set_timer(unsigned intervalMsec, ID id) {
if (_validIds.count(id)) {
LOG_DEBUG() << "coarse timer: existing id " << std::hex << id << std::dec;
BEAM_LOG_DEBUG() << "coarse timer: existing id " << std::hex << id << std::dec;
return make_unexpected(EC_EINVAL);
}
if (intervalMsec > 0 && intervalMsec < unsigned(-1) - _resolution) {
Expand Down
Loading

0 comments on commit e893269

Please sign in to comment.