Skip to content

Commit e171915

Browse files
committed
Countable yamux and yamux read buffer
1 parent fc02b0c commit e171915

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/libp2p/muxer/yamux/yamuxed_connection.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818

1919
namespace libp2p::connection {
2020

21+
class CountableBuffer : public std::vector<uint8_t> {
22+
public:
23+
LIBP2P_METRICS_INSTANCE_COUNT_IF_ENABLED(
24+
libp2p::connection::CountableBuffer);
25+
};
26+
27+
2128
/**
2229
* Implementation of stream multiplexer - connection, which has only one
2330
* physical link to another peer, but many logical streams, for example, for
@@ -193,7 +200,7 @@ namespace libp2p::connection {
193200
bool started_ = false;
194201

195202
/// TODO(artem): change read() interface to reduce copying
196-
std::shared_ptr<Buffer> raw_read_buffer_;
203+
std::shared_ptr<CountableBuffer> raw_read_buffer_;
197204

198205
/// Buffering and segmenting
199206
YamuxReadingState reading_state_;

src/muxer/yamux/yamuxed_connection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace libp2p::connection {
3737
: config_(config),
3838
connection_(std::move(connection)),
3939
scheduler_(std::move(scheduler)),
40-
raw_read_buffer_(std::make_shared<Buffer>()),
40+
raw_read_buffer_(std::make_shared<CountableBuffer>()),
4141
reading_state_(
4242
[this](boost::optional<YamuxFrame> header) {
4343
return processHeader(std::move(header));

0 commit comments

Comments
 (0)