1111
1212#include < boost/beast.hpp>
1313
14+ #include < libp2p/basic/write_return_size.hpp>
1415#include < libp2p/common/hexutil.hpp>
1516#include < libp2p/injector/kademlia_injector.hpp>
1617#include < libp2p/log/configurator.hpp>
@@ -43,7 +44,8 @@ class Session : public std::enable_shared_from_this<Session> {
4344 }
4445
4546 stream_->readSome (
46- *incoming_, incoming_->size (),
47+ *incoming_,
48+ incoming_->size (),
4749 [self = shared_from_this ()](libp2p::outcome::result<size_t > result) {
4850 if (not result) {
4951 self->close ();
@@ -66,8 +68,9 @@ class Session : public std::enable_shared_from_this<Session> {
6668 return false ;
6769 }
6870
69- stream_->write (
70- *buffer, buffer->size (),
71+ libp2p::writeReturnSize (
72+ stream_,
73+ *buffer,
7174 [self = shared_from_this (),
7275 buffer](libp2p::outcome::result<size_t > result) {
7376 if (not result) {
@@ -91,7 +94,7 @@ class Session : public std::enable_shared_from_this<Session> {
9194
9295 bool operator <(const Session &other) {
9396 return stream_->remotePeerId ().value ()
94- < other.stream_ ->remotePeerId ().value ();
97+ < other.stream_ ->remotePeerId ().value ();
9598 }
9699
97100 private:
@@ -286,7 +289,8 @@ int main(int argc, char *argv[]) {
286289
287290 std::function<void ()> find_providers = [&] {
288291 [[maybe_unused]] auto res1 = kademlia->findProviders (
289- content_id, 0 ,
292+ content_id,
293+ 0 ,
290294 [&](libp2p::outcome::result<std::vector<libp2p::peer::PeerInfo>>
291295 res) {
292296 scheduler.schedule (std::function{find_providers},
@@ -350,7 +354,8 @@ int main(int argc, char *argv[]) {
350354 // same content id
351355 std::function<void ()> read_from_console = [&] {
352356 in.async_read_some (boost::asio::buffer (buffer), [&](auto ec, auto size) {
353- auto i = std::find_if (buffer.begin (), buffer.begin () + size + 1 ,
357+ auto i = std::find_if (buffer.begin (),
358+ buffer.begin () + size + 1 ,
354359 [](auto c) { return c == ' \n ' ; });
355360
356361 if (i != buffer.begin () + size + 1 ) {
0 commit comments