Skip to content

Commit 7565619

Browse files
committed
Restore implementation of send proxy logging.
1 parent 279fb25 commit 7565619

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

include/bitcoin/network/channels/channel_peer.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,26 @@ class BCT_API channel_peer
5858
inline void send(const Message& message, result_handler&& handler) NOEXCEPT
5959
{
6060
BC_ASSERT(stranded());
61+
using namespace messages::peer;
6162

6263
// TODO: move to serializer.
6364
const auto magic = settings().identifier;
6465
const auto version = negotiated_version();
65-
const auto ptr = messages::peer::serialize(message, magic, version);
66+
const auto payload = serialize(message, magic, version);
67+
68+
LOGX("Sent " << heading::get_command(*payload) << " to ["
69+
<< endpoint() << "] (" << system::floored_subtract(payload->size(),
70+
heading::command_size) << " bytes)");
6671

6772
using namespace std::placeholders;
6873
count_handler complete = std::bind(&channel_peer::handle_send,
69-
shared_from_base<channel_peer>(), _1, _2, ptr, std::move(handler));
74+
shared_from_base<channel_peer>(), _1, _2, payload,
75+
std::move(handler));
7076

71-
if (!ptr)
77+
if (!payload)
7278
complete(error::bad_alloc, {});
7379
else
74-
write({ ptr->data(), ptr->size() }, std::move(complete));
80+
write({ payload->data(), payload->size() }, std::move(complete));
7581
}
7682

7783
/// Construct a p2p channel to encapsulate and communicate on the socket.
@@ -138,7 +144,8 @@ class BCT_API channel_peer
138144

139145
private:
140146
void log_message(const std::string_view& name, size_t size) const NOEXCEPT;
141-
void handle_send(const code& ec, size_t size, const system::chunk_cptr&,
147+
void handle_send(const code& ec, size_t size,
148+
const system::chunk_cptr& payload,
142149
const result_handler& handler) NOEXCEPT;
143150

144151
// Only passes static member get_area(), so safe to use statically.

src/channels/channel_peer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,19 @@ void channel_peer::handle_read_payload(const code& ec, size_t payload_size,
317317
}
318318

319319
void channel_peer::handle_send(const code& ec, size_t,
320-
const system::chunk_cptr&, const result_handler& handler) NOEXCEPT
320+
const system::chunk_cptr& payload, const result_handler& handler) NOEXCEPT
321321
{
322322
if (ec)
323323
stop(ec);
324324

325+
if (ec != error::peer_disconnect && ec != error::operation_canceled &&
326+
ec != error::connect_failed)
327+
{
328+
LOGF("Send failure " << heading::get_command(*payload) << " to ["
329+
<< endpoint() << "] (" << system::floored_subtract(payload->size(),
330+
heading::command_size) << " bytes) " << ec.message());
331+
}
332+
325333
handler(ec);
326334
}
327335

src/net/proxy.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ void proxy::handle_write(const code& ec, size_t bytes,
346346
return;
347347
}
348348

349-
// BUGBUG: payload changed from data_chunk_ptr to const_buffer.
350-
// TODO: messages dependency, move to channel.
351-
////LOGX("Sent " << heading::get_command(*payload) << " to ["
352-
//// << endpoint() << "] (" << payload->size() << " bytes)");
353-
354349
handler(ec, bytes);
355350
}
356351

0 commit comments

Comments
 (0)