diff --git a/example/01-echo/libp2p_echo_client.cpp b/example/01-echo/libp2p_echo_client.cpp index d516f7167..d9d4ace48 100644 --- a/example/01-echo/libp2p_echo_client.cpp +++ b/example/01-echo/libp2p_echo_client.cpp @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { // Additional logging config for application logger_config)); auto r = logging_system->configure(); - if (not r.message.empty()) { + if (!r.message.empty()) { (r.has_error ? std::cerr : std::cout) << r.message << std::endl; } if (r.has_error) { diff --git a/example/01-echo/libp2p_echo_server.cpp b/example/01-echo/libp2p_echo_server.cpp index af7d70365..8eba066f9 100644 --- a/example/01-echo/libp2p_echo_server.cpp +++ b/example/01-echo/libp2p_echo_server.cpp @@ -90,7 +90,7 @@ int main(int argc, char **argv) { // Additional logging config for application logger_config)); auto r = logging_system->configure(); - if (not r.message.empty()) { + if (!r.message.empty()) { (r.has_error ? std::cerr : std::cout) << r.message << std::endl; } if (r.has_error) { diff --git a/example/02-kademlia/rendezvous_chat.cpp b/example/02-kademlia/rendezvous_chat.cpp index 581d42e97..e51fa2231 100644 --- a/example/02-kademlia/rendezvous_chat.cpp +++ b/example/02-kademlia/rendezvous_chat.cpp @@ -49,7 +49,7 @@ class Session : public std::enable_shared_from_this { stream_->readSome( *incoming_, [self = shared_from_this()](outcome::result result) { - if (not result) { + if (!result) { self->close(); std::cout << self->stream_->remotePeerId().value().toBase58() << " - closed at reading" << std::endl; @@ -74,7 +74,7 @@ class Session : public std::enable_shared_from_this { stream_, *buffer, [self = shared_from_this(), buffer](outcome::result result) { - if (not result) { + if (!result) { self->close(); std::cout << self->stream_->remotePeerId().value().toBase58() << " - closed at writting" << std::endl; @@ -128,7 +128,7 @@ void handleIncomingStream(libp2p::StreamAndProtocol stream_and_protocol) { } void handleOutgoingStream(libp2p::StreamAndProtocolOrError stream_res) { - if (not stream_res) { + if (!stream_res) { fmt::println( std::cerr, " ! outgoing connection failed: {}", stream_res.error()); return; @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) { // Additional logging config for application logger_config)); auto r = logging_system->configure(); - if (not r.message.empty()) { + if (!r.message.empty()) { (r.has_error ? std::cerr : std::cout) << r.message << std::endl; } if (r.has_error) { @@ -295,7 +295,7 @@ int main(int argc, char *argv[]) { scheduler.schedule(std::function{find_providers}, kademlia_config.randomWalk.interval); - if (not res) { + if (!res) { fmt::println(std::cerr, "Cannot find providers: {}", res.error()); return; } @@ -317,7 +317,7 @@ int main(int argc, char *argv[]) { post(*io, [&] { auto listen = host->listen(ma); - if (not listen) { + if (!listen) { fmt::println(std::cerr, "Cannot listen address {}. Error: {}", ma.getStringAddress(), diff --git a/example/03-gossip/gossip_chat_example.cpp b/example/03-gossip/gossip_chat_example.cpp index a523d59c8..c5f024c27 100644 --- a/example/03-gossip/gossip_chat_example.cpp +++ b/example/03-gossip/gossip_chat_example.cpp @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { // Additional logging config for application logger_config)); auto r = logging_system->configure(); - if (not r.message.empty()) { + if (!r.message.empty()) { (r.has_error ? std::cerr : std::cout) << r.message << std::endl; } if (r.has_error) { diff --git a/example/04-dnstxt/ares_resolver.cpp b/example/04-dnstxt/ares_resolver.cpp index 0b940c2ba..8d632bb1a 100644 --- a/example/04-dnstxt/ares_resolver.cpp +++ b/example/04-dnstxt/ares_resolver.cpp @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { // Additional logging config for application logger_config)); auto r = logging_system->configure(); - if (not r.message.empty()) { + if (!r.message.empty()) { (r.has_error ? std::cerr : std::cout) << r.message << std::endl; } if (r.has_error) { diff --git a/include/libp2p/basic/read.hpp b/include/libp2p/basic/read.hpp index 3ae94c993..349cb89c8 100644 --- a/include/libp2p/basic/read.hpp +++ b/include/libp2p/basic/read.hpp @@ -36,7 +36,7 @@ namespace libp2p { } // read remaining bytes auto reader = weak.lock(); - if (not reader) { + if (!reader) { return cb(make_error_code(boost::asio::error::operation_aborted)); } read(reader, out.subspan(n), std::move(cb)); diff --git a/include/libp2p/basic/write.hpp b/include/libp2p/basic/write.hpp index d8153acf7..35e46d768 100644 --- a/include/libp2p/basic/write.hpp +++ b/include/libp2p/basic/write.hpp @@ -36,7 +36,7 @@ namespace libp2p { } // write remaining bytes auto writer = weak.lock(); - if (not writer) { + if (!writer) { return cb(make_error_code(boost::asio::error::operation_aborted)); } write(writer, in.subspan(n), std::move(cb)); diff --git a/include/libp2p/common/outcome_macro.hpp b/include/libp2p/common/outcome_macro.hpp index 7de40dbf7..0bade544f 100644 --- a/include/libp2p/common/outcome_macro.hpp +++ b/include/libp2p/common/outcome_macro.hpp @@ -11,7 +11,7 @@ #define _IF_ERROR_CB_RETURN(tmp, r) \ ({ \ auto &&_r = r; \ - if (not _r.has_value()) { \ + if (!_r.has_value()) { \ return cb(_r.error()); \ } \ _r.value(); \ diff --git a/include/libp2p/injector/network_injector.hpp b/include/libp2p/injector/network_injector.hpp index 30d59b656..4c9a7d835 100644 --- a/include/libp2p/injector/network_injector.hpp +++ b/include/libp2p/injector/network_injector.hpp @@ -160,7 +160,7 @@ namespace libp2p::injector { */ inline auto useWssPem(std::string_view pem) { layer::WssCertificate cert; - if (not pem.empty()) { + if (!pem.empty()) { if (auto cert_res = layer::WssCertificate::make(pem)) { cert = std::move(cert_res.value()); } else { diff --git a/include/libp2p/transport/tcp/tcp_util.hpp b/include/libp2p/transport/tcp/tcp_util.hpp index c7186e19c..41fc470ba 100644 --- a/include/libp2p/transport/tcp/tcp_util.hpp +++ b/include/libp2p/transport/tcp/tcp_util.hpp @@ -128,7 +128,7 @@ namespace libp2p::transport::detail { auto v = ma.getProtocolsWithValues(); auto it = v.begin(); OUTCOME_TRY(addr, readTcpOrUdp(it, v.end())); - if (not addr.udp) { + if (!addr.udp) { return std::errc::protocol_not_supported; } if (it == v.end()) { @@ -185,7 +185,7 @@ namespace libp2p::transport::detail { const boost::asio::ip::tcp::endpoint &endpoint, const ProtoAddrVec &layers) { OUTCOME_TRY(s, toMultiaddr(endpoint)); - if (not layers.empty()) { + if (!layers.empty()) { auto &protocol = layers.at(0).first.code; if (protocol == P::WS) { s += "/ws"; diff --git a/src/basic/scheduler/scheduler_impl.cpp b/src/basic/scheduler/scheduler_impl.cpp index 1f538f7fc..eb337c141 100644 --- a/src/basic/scheduler/scheduler_impl.cpp +++ b/src/basic/scheduler/scheduler_impl.cpp @@ -20,7 +20,7 @@ namespace libp2p::basic { Callback &&cb, std::chrono::milliseconds delay_from_now, bool make_handle) { - if (not cb) { + if (!cb) { throw std::logic_error{"SchedulerImpl::scheduleImpl empty cb arg"}; } @@ -28,11 +28,11 @@ namespace libp2p::basic { if (Time::zero() < delay_from_now) { abs = backend_->now() + delay_from_now; } - if (not make_handle) { + if (!make_handle) { backend_->post( [weak_self{weak_from_this()}, cb{std::move(cb)}, abs]() mutable { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->callbacks_.emplace(abs, std::move(cb)); @@ -45,7 +45,7 @@ namespace libp2p::basic { backend_->post( [weak_self{weak_from_this()}, abs, cancel{std::move(cancel)}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } if (cancel->cancelled.test()) { @@ -57,26 +57,26 @@ namespace libp2p::basic { return cancelFn( [weak_self{weak_from_this()}, weak_cancel{std::move(weak_cancel)}] { auto cancel = weak_cancel.lock(); - if (not cancel) { + if (!cancel) { return; } if (cancel->cancelled.test_and_set()) { return; } auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->backend_->post([weak_self, weak_cancel] { auto cancel = weak_cancel.lock(); - if (not cancel) { + if (!cancel) { return; } - if (not cancel->it) { + if (!cancel->it) { return; } auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->callbacks_.erase(*cancel->it); diff --git a/src/connection/loopback_stream.cpp b/src/connection/loopback_stream.cpp index d1e065204..d5f2142ed 100644 --- a/src/connection/loopback_stream.cpp +++ b/src/connection/loopback_stream.cpp @@ -19,7 +19,7 @@ namespace libp2p::connection { boost::asio::post( ctx, [wptr{std::move(wptr)}, cb{std::move(cb)}, arg{std::move(arg)}]() { - if (not wptr.expired()) { + if (!wptr.expired()) { cb(arg); } }); @@ -154,7 +154,7 @@ namespace libp2p::connection { } // subscribe to new data updates - if (not data_notifyee_) { + if (!data_notifyee_) { data_notifyee_ = std::move(read_lambda); } } diff --git a/src/crypto/hmac_provider/hmac_provider_ctr_impl.cpp b/src/crypto/hmac_provider/hmac_provider_ctr_impl.cpp index 13b4f9c06..09e194379 100644 --- a/src/crypto/hmac_provider/hmac_provider_ctr_impl.cpp +++ b/src/crypto/hmac_provider/hmac_provider_ctr_impl.cpp @@ -52,7 +52,7 @@ namespace libp2p::crypto::hmac { } outcome::result HmacProviderCtrImpl::write(BytesIn data) { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (1 != HMAC_Update(hmac_ctx_, data.data(), data.size())) { @@ -62,7 +62,7 @@ namespace libp2p::crypto::hmac { } outcome::result HmacProviderCtrImpl::digestOut(BytesOut out) const { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (out.size() != digestSize()) { diff --git a/src/crypto/sha/sha1.cpp b/src/crypto/sha/sha1.cpp index 92274ae27..f6cc97e46 100644 --- a/src/crypto/sha/sha1.cpp +++ b/src/crypto/sha/sha1.cpp @@ -19,7 +19,7 @@ namespace libp2p::crypto { } outcome::result Sha1::write(BytesIn data) { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (1 != SHA1_Update(&ctx_, data.data(), data.size())) { @@ -29,7 +29,7 @@ namespace libp2p::crypto { } outcome::result Sha1::digestOut(BytesOut out) const { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (out.size() != digestSize()) { diff --git a/src/crypto/sha/sha256.cpp b/src/crypto/sha/sha256.cpp index a5c837c1c..eef630898 100644 --- a/src/crypto/sha/sha256.cpp +++ b/src/crypto/sha/sha256.cpp @@ -21,7 +21,7 @@ namespace libp2p::crypto { } outcome::result Sha256::write(BytesIn data) { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (1 != SHA256_Update(&ctx_, data.data(), data.size())) { @@ -31,7 +31,7 @@ namespace libp2p::crypto { } outcome::result Sha256::digestOut(BytesOut out) const { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (out.size() != digestSize()) { diff --git a/src/crypto/sha/sha512.cpp b/src/crypto/sha/sha512.cpp index 030e66b93..dcfd73ce6 100644 --- a/src/crypto/sha/sha512.cpp +++ b/src/crypto/sha/sha512.cpp @@ -21,7 +21,7 @@ namespace libp2p::crypto { } outcome::result Sha512::write(BytesIn data) { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (1 != SHA512_Update(&ctx_, data.data(), data.size())) { @@ -31,7 +31,7 @@ namespace libp2p::crypto { } outcome::result Sha512::digestOut(BytesOut out) const { - if (not initialized_) { + if (!initialized_) { return HmacProviderError::FAILED_INITIALIZE_CONTEXT; } if (out.size() != digestSize()) { diff --git a/src/host/basic_host/basic_host.cpp b/src/host/basic_host/basic_host.cpp index 62487d104..a092ccdeb 100644 --- a/src/host/basic_host/basic_host.cpp +++ b/src/host/basic_host/basic_host.cpp @@ -72,7 +72,7 @@ namespace libp2p::host { } } } - if (not is_good_addr) { + if (!is_good_addr) { i = unique_addresses.erase(i); } else { ++i; diff --git a/src/layer/websocket/ws_connection.cpp b/src/layer/websocket/ws_connection.cpp index 39cd3e4d2..16cec576d 100644 --- a/src/layer/websocket/ws_connection.cpp +++ b/src/layer/websocket/ws_connection.cpp @@ -39,7 +39,7 @@ namespace libp2p::connection { } void WsConnection::stop() { - if (not started_) { + if (!started_) { log_->error("already stopped (double stop)"); return; } diff --git a/src/layer/websocket/wss_adaptor.cpp b/src/layer/websocket/wss_adaptor.cpp index b9890f516..bee6456d3 100644 --- a/src/layer/websocket/wss_adaptor.cpp +++ b/src/layer/websocket/wss_adaptor.cpp @@ -43,7 +43,7 @@ namespace libp2p::layer { void WssAdaptor::upgradeInbound( std::shared_ptr conn, LayerAdaptor::LayerConnCallbackFunc cb) const { - if (not server_certificate_.context) { + if (!server_certificate_.context) { return cb(std::errc::address_family_not_supported); } auto ssl = std::make_shared( diff --git a/src/multi/converters/converter_utils.cpp b/src/multi/converters/converter_utils.cpp index 933a8f166..8de89e307 100644 --- a/src/multi/converters/converter_utils.cpp +++ b/src/multi/converters/converter_utils.cpp @@ -191,7 +191,7 @@ namespace libp2p::multi::converters { }; auto uvar = [&]() -> outcome::result { auto var = UVarint::create(bytes); - if (not var) { + if (!var) { return ConversionError::INVALID_ADDRESS; } bytes = bytes.subspan(var->size()); diff --git a/src/multi/multiaddress.cpp b/src/multi/multiaddress.cpp index 50accdd4d..145564949 100644 --- a/src/multi/multiaddress.cpp +++ b/src/multi/multiaddress.cpp @@ -107,7 +107,7 @@ namespace libp2p::multi { } std::string proto_str = '/' + std::string(p->name); - if (not address.empty()) { + if (!address.empty()) { proto_str += '/'; proto_str += address; } diff --git a/src/muxer/mplex/mplex_stream.cpp b/src/muxer/mplex/mplex_stream.cpp index ecf06cdf4..b15d51afe 100644 --- a/src/muxer/mplex/mplex_stream.cpp +++ b/src/muxer/mplex/mplex_stream.cpp @@ -120,7 +120,7 @@ namespace libp2p::connection { std::lock_guard lock(self->write_queue_mutex_); // check if new write messages were received while stream was writing // and propagate these messages - if (not self->write_queue_.empty()) { + if (!self->write_queue_.empty()) { auto [in, cb] = self->write_queue_.front(); self->write_queue_.pop_front(); self->writeSome(in, cb); diff --git a/src/muxer/yamux/yamuxed_connection.cpp b/src/muxer/yamux/yamuxed_connection.cpp index 96b311c04..3f2a8c55b 100644 --- a/src/muxer/yamux/yamuxed_connection.cpp +++ b/src/muxer/yamux/yamuxed_connection.cpp @@ -660,7 +660,7 @@ namespace libp2p::connection { is_writing_ = false; - if (not write_queue_.empty()) { + if (!write_queue_.empty()) { auto next_packet = std::move(write_queue_.front()); write_queue_.pop_front(); doWrite(std::move(next_packet)); @@ -723,10 +723,10 @@ namespace libp2p::connection { cleanup_handle_ = scheduler_->scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } - if (not self->started_) { + if (!self->started_) { return; } std::vector abandoned; @@ -751,14 +751,14 @@ namespace libp2p::connection { ping_handle_ = scheduler_->scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } - if (not self->started_) { + if (!self->started_) { return; } // dont send pings if something is being written - if (not self->is_writing_) { + if (!self->is_writing_) { self->enqueue(pingOutMsg(++self->ping_counter_)); SL_TRACE(log(), "written ping message #{}", self->ping_counter_); } diff --git a/src/network/cares/cares.cpp b/src/network/cares/cares.cpp index 950c2aacb..d75a926ad 100644 --- a/src/network/cares/cares.cpp +++ b/src/network/cares/cares.cpp @@ -73,7 +73,7 @@ namespace libp2p::network::c_ares { Ares::Ares() { bool expected{false}; bool first_init = initialized_.compare_exchange_strong(expected, true); - if (not first_init) { + if (!first_init) { // atomic change failed, thus it was already initialized SL_DEBUG(log(), "C-ares library got initialized more than once"); } else if (auto status = ::ares_library_init(ARES_LIB_INIT_ALL); @@ -98,7 +98,7 @@ namespace libp2p::network::c_ares { const std::string &uri, const std::weak_ptr &io_context, Ares::TxtCallback callback) { - if (not initialized_.load()) { + if (!initialized_.load()) { SL_DEBUG( log(), "Unable to execute DNS TXT request to {} due to c-ares library is " diff --git a/src/network/impl/connection_manager_impl.cpp b/src/network/impl/connection_manager_impl.cpp index d70fb2f17..4832839cd 100644 --- a/src/network/impl/connection_manager_impl.cpp +++ b/src/network/impl/connection_manager_impl.cpp @@ -26,7 +26,7 @@ namespace libp2p::network { std::vector out; out.reserve(it->second.size()); for (const auto &conn : it->second) { - if (not conn->isClosed()) { + if (!conn->isClosed()) { out.emplace_back(conn); } } @@ -72,7 +72,7 @@ namespace libp2p::network { size_t total_connections = 0; for (const auto &entry : connections_) { for (const auto &conn : entry.second) { - if (not conn->isClosed()) { + if (!conn->isClosed()) { ++total_connections; } } @@ -81,7 +81,7 @@ namespace libp2p::network { for (const auto &entry : connections_) { for (const auto &conn : entry.second) { - if (not conn->isClosed()) { + if (!conn->isClosed()) { out.emplace_back(conn); } } diff --git a/src/network/impl/dialer_impl.cpp b/src/network/impl/dialer_impl.cpp index f9f3b0f69..819763b50 100644 --- a/src/network/impl/dialer_impl.cpp +++ b/src/network/impl/dialer_impl.cpp @@ -68,7 +68,7 @@ namespace libp2p::network { auto &&ctx = ctx_found->second; if (ctx.addr_queue.empty()) { - if (not ctx.dialled) { + if (!ctx.dialled) { completeDial(peer_id, std::errc::address_family_not_supported); return; } diff --git a/src/network/impl/dnsaddr_resolver_impl.cpp b/src/network/impl/dnsaddr_resolver_impl.cpp index 7af29a08f..aab4b195f 100644 --- a/src/network/impl/dnsaddr_resolver_impl.cpp +++ b/src/network/impl/dnsaddr_resolver_impl.cpp @@ -52,7 +52,7 @@ namespace libp2p::network { std::all_of(lines.begin(), lines.end(), [](const std::string &line) { return 0 == line.rfind("dnsaddr=", 0); }); - if (not prefixed) { + if (!prefixed) { cb(Error::MALFORMED_RESPONSE); return; } @@ -80,7 +80,7 @@ namespace libp2p::network { outcome::result DnsaddrResolverImpl::dnsaddrUriFromMultiaddr( const multi::Multiaddress &address) { - if (not address.hasProtocol(kDnsaddr)) { + if (!address.hasProtocol(kDnsaddr)) { return Error::INVALID_DNSADDR; } OUTCOME_TRY(hostname, address.getFirstValueForProtocol(kDnsaddr)); diff --git a/src/peer/address_repository/inmem_address_repository.cpp b/src/peer/address_repository/inmem_address_repository.cpp index 518083580..2692cf546 100644 --- a/src/peer/address_repository/inmem_address_repository.cpp +++ b/src/peer/address_repository/inmem_address_repository.cpp @@ -18,7 +18,7 @@ namespace libp2p::peer { void InmemAddressRepository::bootstrap(const multi::Multiaddress &ma, std::function cb) { - if (not isNewDnsAddr(ma)) { + if (!isNewDnsAddr(ma)) { return; // just skip silently circular references among dnsaddrs } dnsaddr_resolver_->load( @@ -141,10 +141,10 @@ namespace libp2p::peer { return; } auto &peer = peer_it->second; - if (not peer.expires.contains(addr)) { + if (!peer.expires.contains(addr)) { return; } - if (not peer.eraseOrder(addr)) { + if (!peer.eraseOrder(addr)) { return; } peer.order.emplace_back(addr); diff --git a/src/protocol/echo/client_echo_session.cpp b/src/protocol/echo/client_echo_session.cpp index 07a0dc726..14ceabdfc 100644 --- a/src/protocol/echo/client_echo_session.cpp +++ b/src/protocol/echo/client_echo_session.cpp @@ -75,7 +75,7 @@ namespace libp2p::protocol { if (ec_) { then(*ec_); } else { - if (not std::equal( + if (!std::equal( recv_buf_.begin(), recv_buf_.end(), buf_.begin(), buf_.end())) { log::createLogger("Echo")->error( "ClientEchoSession: send and receive buffers mismatch"); diff --git a/src/protocol/gossip/impl/gossip_core.cpp b/src/protocol/gossip/impl/gossip_core.cpp index 2ee17239e..72157f977 100644 --- a/src/protocol/gossip/impl/gossip_core.cpp +++ b/src/protocol/gossip/impl/gossip_core.cpp @@ -379,7 +379,7 @@ namespace libp2p::protocol::gossip { heartbeat_timer_ = scheduler_->scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->onHeartbeat(); diff --git a/src/protocol/gossip/impl/stream.cpp b/src/protocol/gossip/impl/stream.cpp index 2b18a9f47..d1210b34f 100644 --- a/src/protocol/gossip/impl/stream.cpp +++ b/src/protocol/gossip/impl/stream.cpp @@ -161,7 +161,7 @@ namespace libp2p::protocol::gossip { *buffer, [weak_self{weak_from_this()}, buffer](outcome::result result) { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->onMessageWritten(result); diff --git a/src/protocol/kademlia/impl/add_provider_executor.cpp b/src/protocol/kademlia/impl/add_provider_executor.cpp index e53591098..e98871b09 100644 --- a/src/protocol/kademlia/impl/add_provider_executor.cpp +++ b/src/protocol/kademlia/impl/add_provider_executor.cpp @@ -82,7 +82,7 @@ namespace libp2p::protocol::kademlia { void AddProviderExecutor::done() { bool x = false; - if (not done_.compare_exchange_strong(x, true)) { + if (!done_.compare_exchange_strong(x, true)) { return; } @@ -158,7 +158,7 @@ namespace libp2p::protocol::kademlia { } void AddProviderExecutor::onConnected(StreamAndProtocolOrError stream_res) { - if (not stream_res) { + if (!stream_res) { --requests_in_progress_; log_.debug("cannot connect to peer: {}; done {}, active {}, in queue {}", diff --git a/src/protocol/kademlia/impl/content_routing_table_impl.cpp b/src/protocol/kademlia/impl/content_routing_table_impl.cpp index e2bcad553..367b060f1 100644 --- a/src/protocol/kademlia/impl/content_routing_table_impl.cpp +++ b/src/protocol/kademlia/impl/content_routing_table_impl.cpp @@ -91,7 +91,7 @@ namespace libp2p::protocol::kademlia { cleanup_timer_ = scheduler_.scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->onCleanupTimer(); diff --git a/src/protocol/kademlia/impl/find_peer_executor.cpp b/src/protocol/kademlia/impl/find_peer_executor.cpp index 80b53d133..96df84da6 100644 --- a/src/protocol/kademlia/impl/find_peer_executor.cpp +++ b/src/protocol/kademlia/impl/find_peer_executor.cpp @@ -63,7 +63,7 @@ namespace libp2p::protocol::kademlia { serialized_request_ = std::make_shared>(); boost::optional self_announce; - if (not config_.passiveMode) { + if (!config_.passiveMode) { self_announce = host_->getPeerInfo(); } @@ -91,7 +91,7 @@ namespace libp2p::protocol::kademlia { void FindPeerExecutor::done(outcome::result result) { bool x = false; - if (not done_.compare_exchange_strong(x, true)) { + if (!done_.compare_exchange_strong(x, true)) { return; } if (result.has_value()) { @@ -169,7 +169,7 @@ namespace libp2p::protocol::kademlia { } void FindPeerExecutor::onConnected(StreamAndProtocolOrError stream_res) { - if (not stream_res) { + if (!stream_res) { --requests_in_progress_; log_.debug("cannot connect to peer: {}; active {}, in queue {}", @@ -216,7 +216,7 @@ namespace libp2p::protocol::kademlia { }); // Check if gotten some message - if (not msg_res) { + if (!msg_res) { log_.warn("Result from {} is failed: {}; active {}, in queue {}", session->stream()->remotePeerId().value().toBase58(), msg_res.error(), @@ -227,7 +227,7 @@ namespace libp2p::protocol::kademlia { auto &msg = msg_res.value(); // Skip inappropriate messages - if (not match(msg)) { + if (!match(msg)) { BOOST_UNREACHABLE_RETURN(); } @@ -259,7 +259,7 @@ namespace libp2p::protocol::kademlia { std::span(peer.info.addresses.data(), peer.info.addresses.size()), peer::ttl::kDay); - if (not add_addr_res) { + if (!add_addr_res) { continue; } diff --git a/src/protocol/kademlia/impl/find_providers_executor.cpp b/src/protocol/kademlia/impl/find_providers_executor.cpp index 5c961d133..b0b72d56e 100644 --- a/src/protocol/kademlia/impl/find_providers_executor.cpp +++ b/src/protocol/kademlia/impl/find_providers_executor.cpp @@ -71,7 +71,7 @@ namespace libp2p::protocol::kademlia { serialized_request_ = std::make_shared>(); boost::optional self_announce; - if (not config_.passiveMode) { + if (!config_.passiveMode) { self_announce = host_->getPeerInfo(); } @@ -99,7 +99,7 @@ namespace libp2p::protocol::kademlia { void FindProvidersExecutor::done() { bool x = false; - if (not done_.compare_exchange_strong(x, true)) { + if (!done_.compare_exchange_strong(x, true)) { return; } @@ -183,7 +183,7 @@ namespace libp2p::protocol::kademlia { } void FindProvidersExecutor::onConnected(StreamAndProtocolOrError stream_res) { - if (not stream_res) { + if (!stream_res) { --requests_in_progress_; log_.debug("cannot connect to peer: {}; active {}, in queue {}", @@ -232,7 +232,7 @@ namespace libp2p::protocol::kademlia { }); // Check if gotten some message - if (not msg_res) { + if (!msg_res) { log_.warn("Result from {} is failed: {}; active {}, in queue {}", session->stream()->remotePeerId().value().toBase58(), msg_res.error(), @@ -243,7 +243,7 @@ namespace libp2p::protocol::kademlia { auto &msg = msg_res.value(); // Skip inappropriate messages - if (not match(msg)) { + if (!match(msg)) { BOOST_UNREACHABLE_RETURN(); } @@ -273,7 +273,7 @@ namespace libp2p::protocol::kademlia { std::span(peer.info.addresses.data(), peer.info.addresses.size()), peer::ttl::kDay); - if (not add_addr_res) { + if (!add_addr_res) { continue; } @@ -302,7 +302,7 @@ namespace libp2p::protocol::kademlia { std::span(peer.info.addresses.data(), peer.info.addresses.size()), peer::ttl::kDay); - if (not add_addr_res) { + if (!add_addr_res) { continue; } diff --git a/src/protocol/kademlia/impl/get_value_executor.cpp b/src/protocol/kademlia/impl/get_value_executor.cpp index 29d4c8423..e4211cc9a 100644 --- a/src/protocol/kademlia/impl/get_value_executor.cpp +++ b/src/protocol/kademlia/impl/get_value_executor.cpp @@ -83,7 +83,7 @@ namespace libp2p::protocol::kademlia { serialized_request_ = std::make_shared>(); boost::optional self_announce; - if (not config_.passiveMode) { + if (!config_.passiveMode) { self_announce = host_->getPeerInfo(); } @@ -177,7 +177,7 @@ namespace libp2p::protocol::kademlia { } void GetValueExecutor::onConnected(StreamAndProtocolOrError stream_res) { - if (not stream_res) { + if (!stream_res) { --requests_in_progress_; log_.debug("cannot connect to peer: {}; active {}, in queue {}", @@ -227,7 +227,7 @@ namespace libp2p::protocol::kademlia { }); // Check if gotten some message - if (not msg_res) { + if (!msg_res) { log_.warn("Result from {} failed: {}; active {}, in queue {}", session->stream()->remotePeerId().value().toBase58(), msg_res.error(), @@ -238,7 +238,7 @@ namespace libp2p::protocol::kademlia { auto &msg = msg_res.value(); // Skip inappropriate messages - if (not match(msg)) { + if (!match(msg)) { BOOST_UNREACHABLE_RETURN(); } @@ -268,7 +268,7 @@ namespace libp2p::protocol::kademlia { std::span(peer.info.addresses.data(), peer.info.addresses.size()), peer::ttl::kDay); - if (not add_addr_res) { + if (!add_addr_res) { continue; } @@ -293,7 +293,7 @@ namespace libp2p::protocol::kademlia { auto &value = msg.record.value().value; auto validation_res = validator_->validate(key_, value); - if (not validation_res.has_value()) { + if (!validation_res.has_value()) { log_.debug("Result from {} is invalid", remote_peer_id.toBase58()); return; } @@ -314,7 +314,7 @@ namespace libp2p::protocol::kademlia { [](auto &record) { return record.value; }); auto index_res = validator_->select(key_, values); - if (not index_res.has_value()) { + if (!index_res.has_value()) { log_.debug("Can't select best value of {} provided", values.size()); return; } @@ -336,7 +336,7 @@ namespace libp2p::protocol::kademlia { } } - if (not addressees.empty()) { + if (!addressees.empty()) { auto put_value_executor = executor_factory_->createPutValueExecutor( key_, best, std::move(addressees)); [[maybe_unused]] auto res = put_value_executor->start(); diff --git a/src/protocol/kademlia/impl/kademlia_impl.cpp b/src/protocol/kademlia/impl/kademlia_impl.cpp index 0e42de3e7..4f0fff0dd 100644 --- a/src/protocol/kademlia/impl/kademlia_impl.cpp +++ b/src/protocol/kademlia/impl/kademlia_impl.cpp @@ -109,7 +109,7 @@ namespace libp2p::protocol::kademlia { .getChannel() .subscribe([weak_self{weak_from_this()}](const PeerId &peer) { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } std::ignore = @@ -142,7 +142,7 @@ namespace libp2p::protocol::kademlia { const outcome::result &, std::vector succeeded_peers) { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } std::ignore = self->createPutValueExecutor( @@ -181,7 +181,7 @@ namespace libp2p::protocol::kademlia { content_routing_table_->addProvider(key, self_id_); - if (not need_notify) { + if (!need_notify) { return outcome::success(); } @@ -196,7 +196,7 @@ namespace libp2p::protocol::kademlia { // Try to find locally auto providers = content_routing_table_->getProvidersFor(key, limit); - if (not providers.empty()) { + if (!providers.empty()) { if (limit > 0 && providers.size() > limit) { std::vector result; result.reserve(limit); @@ -254,7 +254,7 @@ namespace libp2p::protocol::kademlia { peer_info.id, std::span(peer_info.addresses.data(), peer_info.addresses.size()), permanent ? peer::ttl::kPermanent : peer::ttl::kDay); - if (not upsert_res) { + if (!upsert_res) { log_.debug("{} was skipped at addind to peer routing table: {}", peer_info.id.toBase58(), upsert_res.error()); @@ -263,7 +263,7 @@ namespace libp2p::protocol::kademlia { auto update_res = peer_routing_table_->update(peer_info.id, permanent, is_connected); - if (not update_res) { + if (!update_res) { log_.debug("{} was not added to peer routing table: {}", peer_info.id.toBase58(), update_res.error()); @@ -286,7 +286,7 @@ namespace libp2p::protocol::kademlia { // Try to find locally auto peer_info = host_->getPeerRepository().getPeerInfo(peer_id); - if (not peer_info.addresses.empty()) { + if (!peer_info.addresses.empty()) { scheduler_->schedule( [handler = std::move(handler), peer_info = std::move(peer_info)] { handler(peer_info, {}); @@ -330,7 +330,7 @@ namespace libp2p::protocol::kademlia { void KademliaImpl::onPutValue(const std::shared_ptr &session, Message &&msg) { - if (not msg.record) { + if (!msg.record) { log_.warn("incoming PutValue failed: no record in message"); return; } @@ -339,7 +339,7 @@ namespace libp2p::protocol::kademlia { log_.debug("MSG: PutValue ({})", multi::detail::encodeBase58(key)); auto validation_res = validator_->validate(key, value); - if (not validation_res) { + if (!validation_res) { log_.warn("incoming PutValue failed: {}", validation_res.error()); return; } @@ -395,7 +395,7 @@ namespace libp2p::protocol::kademlia { void KademliaImpl::onAddProvider(const std::shared_ptr &session, Message &&msg) { - if (not msg.provider_peers) { + if (!msg.provider_peers) { log_.warn("AddProvider failed: no provider_peers im message"); return; } @@ -426,7 +426,7 @@ namespace libp2p::protocol::kademlia { auto peer_ids = content_routing_table_->getProvidersFor( msg.key, config_.closerPeerCount * 2); - if (not peer_ids.empty()) { + if (!peer_ids.empty()) { std::vector peers; peers.reserve(config_.closerPeerCount); @@ -442,7 +442,7 @@ namespace libp2p::protocol::kademlia { } } - if (not peers.empty()) { + if (!peers.empty()) { msg.provider_peers = std::move(peers); } } @@ -450,7 +450,7 @@ namespace libp2p::protocol::kademlia { peer_ids = peer_routing_table_->getNearestPeers( NodeId::hash(msg.key), config_.closerPeerCount * 2); - if (not peer_ids.empty()) { + if (!peer_ids.empty()) { std::vector peers; peers.reserve(config_.closerPeerCount); @@ -466,7 +466,7 @@ namespace libp2p::protocol::kademlia { } } - if (not peers.empty()) { + if (!peers.empty()) { msg.closer_peers = std::move(peers); } } @@ -516,7 +516,7 @@ namespace libp2p::protocol::kademlia { } } - if (not peers.empty()) { + if (!peers.empty()) { msg.closer_peers = std::move(peers); } @@ -655,13 +655,13 @@ namespace libp2p::protocol::kademlia { // Periodic behavior is driven by configuration only; no runtime setters void KademliaImpl::setReplicationTimer() { - if (not config_.periodicReplication.enabled) { + if (!config_.periodicReplication.enabled) { return; } replication_timer_ = scheduler_->scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->setReplicationTimer(); @@ -671,13 +671,13 @@ namespace libp2p::protocol::kademlia { } void KademliaImpl::setRepublishingTimer() { - if (not config_.periodicRepublishing.enabled) { + if (!config_.periodicRepublishing.enabled) { return; } republishing_timer_ = scheduler_->scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->setRepublishingTimer(); diff --git a/src/protocol/kademlia/impl/peer_routing_table_impl.cpp b/src/protocol/kademlia/impl/peer_routing_table_impl.cpp index 460edfb75..00809b909 100644 --- a/src/protocol/kademlia/impl/peer_routing_table_impl.cpp +++ b/src/protocol/kademlia/impl/peer_routing_table_impl.cpp @@ -135,7 +135,7 @@ namespace libp2p::protocol::kademlia { void PeerRoutingTableImpl::remove(const peer::PeerId &peer_id) { auto bucket_index = getBucketIndex(NodeId{peer_id}); - if (not bucket_index) { + if (!bucket_index) { return; } auto &bucket = buckets_.at(*bucket_index); @@ -168,11 +168,11 @@ namespace libp2p::protocol::kademlia { } } } - if (not done()) { + if (!done()) { append(0); } for (size_t i = 1; i < 256 and not done(); ++i) { - if (not bit(i)) { + if (!bit(i)) { append(i); } } @@ -204,7 +204,7 @@ namespace libp2p::protocol::kademlia { bool is_permanent, bool is_connected) { auto bucket_index = getBucketIndex(NodeId{pid}); - if (not bucket_index) { + if (!bucket_index) { return true; } auto &bucket = buckets_.at(*bucket_index); diff --git a/src/protocol/kademlia/impl/put_value_executor.cpp b/src/protocol/kademlia/impl/put_value_executor.cpp index 777d121f9..7bc5a3aed 100644 --- a/src/protocol/kademlia/impl/put_value_executor.cpp +++ b/src/protocol/kademlia/impl/put_value_executor.cpp @@ -111,7 +111,7 @@ namespace libp2p::protocol::kademlia { } void PutValueExecutor::onConnected(StreamAndProtocolOrError stream_res) { - if (not stream_res) { + if (!stream_res) { --requests_in_progress_; log_.debug("cannot connect to peer: {}; active {}, in queue {}", diff --git a/src/protocol/kademlia/impl/session.cpp b/src/protocol/kademlia/impl/session.cpp index 98f0b6fd7..0e85f6fd7 100644 --- a/src/protocol/kademlia/impl/session.cpp +++ b/src/protocol/kademlia/impl/session.cpp @@ -32,12 +32,12 @@ namespace libp2p::protocol::kademlia { framing_->read([self{shared_from_this()}, on_read{std::move(on_read)}]( basic::MessageReadWriter::ReadCallback r) { self->timer_.reset(); - if (not r) { + if (!r) { on_read(r.error()); return; } Message msg; - if (not msg.deserialize(*r.value())) { + if (!msg.deserialize(*r.value())) { on_read(Error::MESSAGE_DESERIALIZE_ERROR); return; } @@ -54,7 +54,7 @@ namespace libp2p::protocol::kademlia { on_write{std::move(on_write)}, buf](outcome::result r) { self->timer_.reset(); - if (not r) { + if (!r) { on_write(r.error()); return; } @@ -67,10 +67,10 @@ namespace libp2p::protocol::kademlia { weak_session_host{std::move(weak_session_host)}]( outcome::result r) { auto session_host = weak_session_host.lock(); - if (not session_host) { + if (!session_host) { return; } - if (not r) { + if (!r) { return; } session_host->onMessage(self, std::move(r.value())); @@ -90,14 +90,14 @@ namespace libp2p::protocol::kademlia { void Session::write(const Message &msg, std::weak_ptr weak_session_host) { Bytes pb; - if (not msg.serialize(pb)) { + if (!msg.serialize(pb)) { return; } write(pb, [self{shared_from_this()}, weak_session_host{std::move(weak_session_host)}]( outcome::result r) { - if (not r) { + if (!r) { return; } self->read(weak_session_host); @@ -109,7 +109,7 @@ namespace libp2p::protocol::kademlia { write( frame, [self{shared_from_this()}, response_handler](outcome::result r) { - if (not r) { + if (!r) { response_handler->onResult(self, r.error()); return; } @@ -126,13 +126,13 @@ namespace libp2p::protocol::kademlia { return; } auto scheduler = scheduler_.lock(); - if (not scheduler) { + if (!scheduler) { return; } timer_ = scheduler->scheduleWithHandle( [weak_self = weak_from_this()] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->stream_->reset(); diff --git a/src/protocol/kademlia/impl/storage_impl.cpp b/src/protocol/kademlia/impl/storage_impl.cpp index 40183eae3..ad06a210c 100644 --- a/src/protocol/kademlia/impl/storage_impl.cpp +++ b/src/protocol/kademlia/impl/storage_impl.cpp @@ -110,7 +110,7 @@ namespace libp2p::protocol::kademlia { refresh_timer_ = scheduler_->scheduleWithHandle( [weak_self{weak_from_this()}] { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } self->onRefreshTimer(); diff --git a/src/protocol/kademlia/message.cpp b/src/protocol/kademlia/message.cpp index 28d2637b4..2101f0262 100644 --- a/src/protocol/kademlia/message.cpp +++ b/src/protocol/kademlia/message.cpp @@ -123,12 +123,12 @@ namespace libp2p::protocol::kademlia { assign_record(record.value(), pb_msg.record()); } auto closer_res = assign_peers(closer_peers, pb_msg.closerpeers()); - if (not closer_res) { + if (!closer_res) { error_message_ = fmt::format("Bad closer peers: {}", closer_res.error()); return false; } auto provider_res = assign_peers(provider_peers, pb_msg.providerpeers()); - if (not provider_res) { + if (!provider_res) { error_message_ = fmt::format("Bad provider peers: {}", provider_res.error()); return false; diff --git a/src/protocol/ping/ping_client_session.cpp b/src/protocol/ping/ping_client_session.cpp index abca88479..2f58e6b14 100644 --- a/src/protocol/ping/ping_client_session.cpp +++ b/src/protocol/ping/ping_client_session.cpp @@ -42,7 +42,7 @@ namespace libp2p::protocol { } void PingClientSession::write() { - if (not is_started_ or closed_ or stream_->isClosedForWrite()) { + if (!is_started_ or closed_ or stream_->isClosedForWrite()) { return; } @@ -73,7 +73,7 @@ namespace libp2p::protocol { } void PingClientSession::read() { - if (not is_started_ or closed_ or stream_->isClosedForRead()) { + if (!is_started_ or closed_ or stream_->isClosedForRead()) { return; } diff --git a/src/security/noise/crypto/state.cpp b/src/security/noise/crypto/state.cpp index 3a35e35ec..334abd4d5 100644 --- a/src/security/noise/crypto/state.cpp +++ b/src/security/noise/crypto/state.cpp @@ -154,7 +154,7 @@ namespace libp2p::security::noise { outcome::result SymmetricState::encryptAndHash(BytesIn precompiled_out, BytesIn plaintext) { - if (not has_key_) { + if (!has_key_) { Bytes result(precompiled_out.size() + plaintext.size()); OUTCOME_TRY(mixHash(plaintext)); std::copy_n( @@ -180,7 +180,7 @@ namespace libp2p::security::noise { outcome::result SymmetricState::decryptAndHash(BytesIn precompiled_out, BytesIn ciphertext) { - if (not has_key_) { + if (!has_key_) { Bytes result(precompiled_out.size() + ciphertext.size()); OUTCOME_TRY(mixHash(ciphertext)); std::copy_n( @@ -298,7 +298,7 @@ namespace libp2p::security::noise { preshared_key_placement = config.preshared_key_placement_.value(); } std::string psk_modifier; - if (not preshared_key_.empty()) { + if (!preshared_key_.empty()) { if (32 != preshared_key_.size()) { return Error::WRONG_PRESHARED_KEY_SIZE; } @@ -328,16 +328,16 @@ namespace libp2p::security::noise { OUTCOME_TRY(symmetric_state_->mixHash(local_static_kp_.pub)); } else if (is_initiator_ and MessagePattern::E == m) { OUTCOME_TRY(symmetric_state_->mixHash(local_ephemeral_kp_.pub)); - } else if (not is_initiator_ and MessagePattern::S == m) { + } else if (!is_initiator_ and MessagePattern::S == m) { OUTCOME_TRY(symmetric_state_->mixHash(remote_static_pubkey_)); - } else if (not is_initiator_ and MessagePattern::E == m) { + } else if (!is_initiator_ and MessagePattern::E == m) { OUTCOME_TRY(symmetric_state_->mixHash(remote_ephemeral_pubkey_)); } } for (const auto &m : config.pattern_.responderPreMessages) { - if (not is_initiator_ and MessagePattern::S == m) { + if (!is_initiator_ and MessagePattern::S == m) { OUTCOME_TRY(symmetric_state_->mixHash(local_static_kp_.pub)); - } else if (not is_initiator_ and MessagePattern::E == m) { + } else if (!is_initiator_ and MessagePattern::E == m) { OUTCOME_TRY(symmetric_state_->mixHash(local_ephemeral_kp_.pub)); } else if (is_initiator_ and MessagePattern::S == m) { OUTCOME_TRY(symmetric_state_->mixHash(remote_static_pubkey_)); @@ -352,7 +352,7 @@ namespace libp2p::security::noise { outcome::result HandshakeState::writeMessage( BytesIn precompiled_out, BytesIn payload) { OUTCOME_TRY(isInitialized()); - if (not should_write_) { + if (!should_write_) { return Error::UNEXPECTED_WRITE_CALL; } if (message_idx_ > static_cast(message_patterns_.size()) - 1) { @@ -409,7 +409,7 @@ namespace libp2p::security::noise { local_ephemeral_kp_.pub.begin(), local_ephemeral_kp_.pub.end()); OUTCOME_TRY(symmetric_state_->mixHash(local_ephemeral_kp_.pub)); - if (not preshared_key_.empty()) { + if (!preshared_key_.empty()) { OUTCOME_TRY(symmetric_state_->mixKey(local_ephemeral_kp_.pub)); } return outcome::success(); @@ -538,7 +538,7 @@ namespace libp2p::security::noise { remote_ephemeral_pubkey_ = Bytes{message.begin(), message.begin() + expected}; OUTCOME_TRY(symmetric_state_->mixHash(remote_ephemeral_pubkey_)); - if (not preshared_key_.empty()) { + if (!preshared_key_.empty()) { OUTCOME_TRY(symmetric_state_->mixKey(remote_ephemeral_pubkey_)); } Bytes(message.begin() + expected, message.end()).swap(message); @@ -553,7 +553,7 @@ namespace libp2p::security::noise { if (static_cast(message.size()) < expected) { return Error::MESSAGE_TOO_SHORT; } - if (not remote_static_pubkey_.empty()) { + if (!remote_static_pubkey_.empty()) { return Error::REMOTE_KEY_ALREADY_SET; } auto decrypted = symmetric_state_->decryptAndHash( diff --git a/src/security/noise/handshake.cpp b/src/security/noise/handshake.cpp index 110ece087..3a91ab787 100644 --- a/src/security/noise/handshake.cpp +++ b/src/security/noise/handshake.cpp @@ -171,7 +171,7 @@ namespace libp2p::security::noise { signature_correct, crypto_provider_->verify( to_verify, handy_payload.identity_sig, handy_payload.identity_key)); - if (not signature_correct) { + if (!signature_correct) { SL_TRACE(log_, "Remote peer's payload signature verification failed"); return std::errc::owner_dead; } @@ -272,11 +272,11 @@ namespace libp2p::security::noise { log_->error("handshake failed, {}", secured.error()); return connection_cb_(secured.error()); } - if (not secured.value()) { + if (!secured.value()) { log_->error("handshake failed for unknown reason"); return connection_cb_(std::errc::io_error); } - if (not remote_peer_pubkey_) { + if (!remote_peer_pubkey_) { log_->error("Remote peer static pubkey remains unknown"); return connection_cb_(std::errc::connection_aborted); } diff --git a/src/security/noise/handshake_message_marshaller_impl.cpp b/src/security/noise/handshake_message_marshaller_impl.cpp index 7fdc72a90..9e03432aa 100644 --- a/src/security/noise/handshake_message_marshaller_impl.cpp +++ b/src/security/noise/handshake_message_marshaller_impl.cpp @@ -61,7 +61,7 @@ namespace libp2p::security::noise { const HandshakeMessage &msg) const { OUTCOME_TRY(proto_msg, handyToProto(msg)); Bytes out_msg(proto_msg.ByteSizeLong()); - if (not proto_msg.SerializeToArray(out_msg.data(), + if (!proto_msg.SerializeToArray(out_msg.data(), static_cast(out_msg.size()))) { return Error::MESSAGE_SERIALIZING_ERROR; } @@ -71,7 +71,7 @@ namespace libp2p::security::noise { outcome::result> HandshakeMessageMarshallerImpl::unmarshal(BytesIn msg_bytes) const { protobuf::NoiseHandshakePayload proto_msg; - if (not proto_msg.ParseFromArray(msg_bytes.data(), + if (!proto_msg.ParseFromArray(msg_bytes.data(), static_cast(msg_bytes.size()))) { return Error::MESSAGE_DESERIALIZING_ERROR; } diff --git a/src/security/noise/noise_connection.cpp b/src/security/noise/noise_connection.cpp index 3b740294c..eaa009537 100644 --- a/src/security/noise/noise_connection.cpp +++ b/src/security/noise/noise_connection.cpp @@ -46,7 +46,7 @@ namespace libp2p::connection { void NoiseConnection::readSome(BytesOut out, libp2p::basic::Reader::ReadCallbackFunc cb) { - if (not frame_buffer_->empty()) { + if (!frame_buffer_->empty()) { auto n{std::min(out.size(), frame_buffer_->size())}; auto begin{frame_buffer_->begin()}; auto end{begin + static_cast(n)}; diff --git a/src/security/secio/secio_connection.cpp b/src/security/secio/secio_connection.cpp index c4f09e558..367d7357e 100644 --- a/src/security/secio/secio_connection.cpp +++ b/src/security/secio/secio_connection.cpp @@ -191,7 +191,7 @@ namespace libp2p::connection { return; } - if (not user_data_buffer_.empty()) { + if (!user_data_buffer_.empty()) { size_t to_read{std::min(user_data_buffer_.size(), out.size())}; popUserData(out, to_read); SL_TRACE(log_, "Successfully read {} bytes", to_read); diff --git a/src/security/secio/secio_dialer.cpp b/src/security/secio/secio_dialer.cpp index 681bdafb5..dc5816f66 100644 --- a/src/security/secio/secio_dialer.cpp +++ b/src/security/secio/secio_dialer.cpp @@ -158,7 +158,7 @@ namespace libp2p::security::secio { outcome::result Dialer::generateSharedSecret( crypto::Buffer remote_ephemeral_public_key) const { - if (not ekey_pair_) { + if (!ekey_pair_) { return Error::INTERNAL_FAILURE; } OUTCOME_TRY(shared_secret, diff --git a/src/security/tls/tls_details.cpp b/src/security/tls/tls_details.cpp index 19e5e804b..8a4687a2d 100644 --- a/src/security/tls/tls_details.cpp +++ b/src/security/tls/tls_details.cpp @@ -58,7 +58,7 @@ namespace libp2p::security::tls_details { bool seen = false; for (int i = 0; i < X509_get_ext_count(cert); i++) { auto *ext = X509_get_ext(cert, i); - if (not X509_EXTENSION_get_critical(ext)) { + if (!X509_EXTENSION_get_critical(ext)) { continue; } if (X509_supported_extension(ext)) { diff --git a/src/transport/quic/connection.cpp b/src/transport/quic/connection.cpp index 68d579740..14ee99e4a 100644 --- a/src/transport/quic/connection.cpp +++ b/src/transport/quic/connection.cpp @@ -95,7 +95,7 @@ namespace libp2p::transport { outcome::result> QuicConnection::newStream() { - if (not conn_ctx_) { + if (!conn_ctx_) { return QuicError::CONN_CLOSED; } OUTCOME_TRY(stream, conn_ctx_->engine->newStream(conn_ctx_)); diff --git a/src/transport/quic/engine.cpp b/src/transport/quic/engine.cpp index 69233be7d..d8e07e5d6 100644 --- a/src/transport/quic/engine.cpp +++ b/src/transport/quic/engine.cpp @@ -39,7 +39,7 @@ namespace libp2p::transport::lsquic { lsquicInit(); auto flags = 0; - if (not client) { + if (!client) { flags |= LSENG_SERVER; } @@ -66,7 +66,7 @@ namespace libp2p::transport::lsquic { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) auto _conn_ctx = reinterpret_cast(conn_ctx); lsquic_conn_set_ctx(conn, _conn_ctx); - if (not op) { + if (!op) { stream_if.on_hsk_done(conn, LSQ_HSK_OK); } return _conn_ctx; @@ -91,7 +91,7 @@ namespace libp2p::transport::lsquic { auto ok = status == LSQ_HSK_OK or status == LSQ_HSK_RESUMED_OK; auto op = qtils::optionTake(conn_ctx->connecting); auto res = [&]() -> outcome::result> { - if (not ok) { + if (!ok) { return QuicError::HANDSHAKE_FAILED; } auto cert = SSL_get_peer_certificate(lsquic_conn_ssl(conn)); @@ -113,7 +113,7 @@ namespace libp2p::transport::lsquic { conn_ctx->conn = conn; return conn; }(); - if (not res) { + if (!res) { lsquic_conn_close(conn); } if (op) { @@ -205,7 +205,7 @@ namespace libp2p::transport::lsquic { auto cb = [weak_self{self->weak_from_this()}]( boost::system::error_code ec) { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } if (ec) { @@ -229,7 +229,7 @@ namespace libp2p::transport::lsquic { }; engine_ = lsquic_engine_new(flags, &api); - if (not engine_) { + if (!engine_) { throw std::logic_error{"lsquic_engine_new"}; } } @@ -283,7 +283,7 @@ namespace libp2p::transport::lsquic { conn_ctx->new_stream.emplace(); lsquic_conn_make_stream(conn_ctx->ls_conn); auto stream = qtils::optionTake(conn_ctx->new_stream).value(); - if (not stream) { + if (!stream) { return QuicError::CANT_OPEN_STREAM; } return stream; @@ -318,7 +318,7 @@ namespace libp2p::transport::lsquic { auto want_flush = std::exchange(want_flush_, {}); for (auto &weak_stream : want_flush) { auto stream = weak_stream.lock(); - if (not stream) { + if (!stream) { continue; } if (stream->stream_ctx_ == nullptr) { @@ -332,13 +332,13 @@ namespace libp2p::transport::lsquic { } lsquic_engine_process_conns(engine_); int us = 0; - if (not lsquic_engine_earliest_adv_tick(engine_, &us)) { + if (!lsquic_engine_earliest_adv_tick(engine_, &us)) { return; } timer_.expires_after(std::chrono::microseconds{us}); auto cb = [weak_self{weak_from_this()}](boost::system::error_code ec) { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } if (ec) { @@ -364,7 +364,7 @@ namespace libp2p::transport::lsquic { auto cb = [weak_self{weak_from_this()}](boost::system::error_code ec) { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } if (ec) { diff --git a/src/transport/quic/listener.cpp b/src/transport/quic/listener.cpp index 40572d927..a340cc389 100644 --- a/src/transport/quic/listener.cpp +++ b/src/transport/quic/listener.cpp @@ -53,7 +53,7 @@ namespace libp2p::transport { } outcome::result QuicListener::getListenMultiaddr() const { - if (not server_) { + if (!server_) { return std::errc::not_connected; } return server_->local(); diff --git a/src/transport/quic/stream.cpp b/src/transport/quic/stream.cpp index 4c923c8d0..f66797aaf 100644 --- a/src/transport/quic/stream.cpp +++ b/src/transport/quic/stream.cpp @@ -26,7 +26,7 @@ namespace libp2p::connection { void QuicStream::readSome(BytesOut out, basic::Reader::ReadCallbackFunc cb) { outcome::result r = QuicError::STREAM_CLOSED; - if (not stream_ctx_) { + if (!stream_ctx_) { return cb(r); } if (stream_ctx_->reading) { @@ -37,7 +37,7 @@ namespace libp2p::connection { stream_ctx_->reading.emplace( [weak_self{weak_from_this()}, out, cb{std::move(cb)}]() mutable { auto self = weak_self.lock(); - if (not self) { + if (!self) { cb(QuicError::STREAM_CLOSED); return; } @@ -59,7 +59,7 @@ namespace libp2p::connection { void QuicStream::writeSome(BytesIn in, basic::Writer::WriteCallbackFunc cb) { outcome::result r = QuicError::STREAM_CLOSED; - if (not stream_ctx_) { + if (!stream_ctx_) { return cb(r); } if (stream_ctx_->writing) { @@ -74,7 +74,7 @@ namespace libp2p::connection { stream_ctx_->writing.emplace( [weak_self{weak_from_this()}, in, cb{std::move(cb)}]() mutable { auto self = weak_self.lock(); - if (not self) { + if (!self) { cb(QuicError::STREAM_CLOSED); return; } @@ -108,7 +108,7 @@ namespace libp2p::connection { } void QuicStream::close(Stream::VoidResultHandlerFunc cb) { - if (not stream_ctx_) { + if (!stream_ctx_) { return cb(outcome::success()); } lsquic_stream_shutdown(stream_ctx_->ls_stream, 1); @@ -116,7 +116,7 @@ namespace libp2p::connection { } void QuicStream::reset() { - if (not stream_ctx_) { + if (!stream_ctx_) { return; } lsquic_stream_close(stream_ctx_->ls_stream); diff --git a/src/transport/quic/transport.cpp b/src/transport/quic/transport.cpp index 2386e26dd..0b1bd683f 100644 --- a/src/transport/quic/transport.cpp +++ b/src/transport/quic/transport.cpp @@ -32,7 +32,7 @@ namespace libp2p::transport { Multiaddress address, TransportAdaptor::HandlerFunc cb) { auto r = detail::asQuic(address); - if (not r) { + if (!r) { return cb(r.error()); } auto &info = r.value(); @@ -41,10 +41,10 @@ namespace libp2p::transport { outcome::result r) mutable { auto self = weak_self.lock(); - if (not self) { + if (!self) { return; } - if (not r) { + if (!r) { return cb(r.error()); } auto remote = r.value().begin()->endpoint(); @@ -55,7 +55,7 @@ namespace libp2p::transport { peer, [cb{std::move(cb)}]( outcome::result> r) { - if (not r) { + if (!r) { return cb(r.error()); } cb(r.value()); diff --git a/src/transport/tcp/tcp_connection.cpp b/src/transport/tcp/tcp_connection.cpp index 890c935f7..e420859d5 100644 --- a/src/transport/tcp/tcp_connection.cpp +++ b/src/transport/tcp/tcp_connection.cpp @@ -126,7 +126,7 @@ namespace libp2p::transport { bool expected = false; if (self->connection_phase_done_.compare_exchange_strong(expected, true)) { - if (not error) { + if (!error) { // timeout happened, timer expired before connection was // established cb(boost::system::error_code{boost::system::errc::timed_out, @@ -149,13 +149,13 @@ namespace libp2p::transport { return; } bool expected = false; - if (not self->connection_phase_done_.compare_exchange_strong(expected, + if (!self->connection_phase_done_.compare_exchange_strong(expected, true)) { BOOST_ASSERT(expected); // connection phase already done - means that user's callback was // already called by timer expiration so we are closing socket if // it was actually connected - if (not ec) { + if (!ec) { self->socket_.close(); } return; diff --git a/src/transport/tcp/tcp_transport.cpp b/src/transport/tcp/tcp_transport.cpp index 182c67caa..153f9fb0a 100644 --- a/src/transport/tcp/tcp_transport.cpp +++ b/src/transport/tcp/tcp_transport.cpp @@ -15,7 +15,7 @@ namespace libp2p::transport { multi::Multiaddress address, TransportAdaptor::HandlerFunc handler) { auto r = detail::asTcp(address); - if (not r) { + if (!r) { return handler(r.error()); } auto &[info, layers] = r.value(); @@ -27,7 +27,7 @@ namespace libp2p::transport { layers = std::move(layers)]( outcome::result r) mutable { - if (not r) { + if (!r) { return handler(r.error()); } conn->connect( diff --git a/test/libp2p/muxer/muxers_and_streams_test.cpp b/test/libp2p/muxer/muxers_and_streams_test.cpp index 390ca3585..9291166a2 100644 --- a/test/libp2p/muxer/muxers_and_streams_test.cpp +++ b/test/libp2p/muxer/muxers_and_streams_test.cpp @@ -270,7 +270,7 @@ namespace libp2p::regression { } void onRead(outcome::result res) { - if (not res.has_value()) { + if (!res.has_value()) { TRACE("({}): read error", stats_.node_id); stats_.put(Stats::READ_FAILURE); } else { @@ -281,7 +281,7 @@ namespace libp2p::regression { } void onWrite(outcome::result res) { - if (not res.has_value()) { + if (!res.has_value()) { TRACE("({}): write error", stats_.node_id); stats_.put(Stats::WRITE_FAILURE); } else {