Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/01-echo/libp2p_echo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion example/01-echo/libp2p_echo_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions example/02-kademlia/rendezvous_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Session : public std::enable_shared_from_this<Session> {
stream_->readSome(
*incoming_,
[self = shared_from_this()](outcome::result<size_t> result) {
if (not result) {
if (!result) {
self->close();
std::cout << self->stream_->remotePeerId().value().toBase58()
<< " - closed at reading" << std::endl;
Expand All @@ -74,7 +74,7 @@ class Session : public std::enable_shared_from_this<Session> {
stream_,
*buffer,
[self = shared_from_this(), buffer](outcome::result<void> result) {
if (not result) {
if (!result) {
self->close();
std::cout << self->stream_->remotePeerId().value().toBase58()
<< " - closed at writting" << std::endl;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion example/03-gossip/gossip_chat_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion example/04-dnstxt/ares_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion include/libp2p/basic/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion include/libp2p/basic/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion include/libp2p/common/outcome_macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); \
Expand Down
2 changes: 1 addition & 1 deletion include/libp2p/injector/network_injector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions include/libp2p/transport/tcp/tcp_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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";
Expand Down
18 changes: 9 additions & 9 deletions src/basic/scheduler/scheduler_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ 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"};
}

auto abs = Time::zero();
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));
Expand All @@ -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()) {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/connection/loopback_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/hmac_provider/hmac_provider_ctr_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace libp2p::crypto::hmac {
}

outcome::result<void> HmacProviderCtrImpl::write(BytesIn data) {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (1 != HMAC_Update(hmac_ctx_, data.data(), data.size())) {
Expand All @@ -62,7 +62,7 @@ namespace libp2p::crypto::hmac {
}

outcome::result<void> HmacProviderCtrImpl::digestOut(BytesOut out) const {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (out.size() != digestSize()) {
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/sha/sha1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace libp2p::crypto {
}

outcome::result<void> Sha1::write(BytesIn data) {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (1 != SHA1_Update(&ctx_, data.data(), data.size())) {
Expand All @@ -29,7 +29,7 @@ namespace libp2p::crypto {
}

outcome::result<void> Sha1::digestOut(BytesOut out) const {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (out.size() != digestSize()) {
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/sha/sha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace libp2p::crypto {
}

outcome::result<void> Sha256::write(BytesIn data) {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (1 != SHA256_Update(&ctx_, data.data(), data.size())) {
Expand All @@ -31,7 +31,7 @@ namespace libp2p::crypto {
}

outcome::result<void> Sha256::digestOut(BytesOut out) const {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (out.size() != digestSize()) {
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/sha/sha512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace libp2p::crypto {
}

outcome::result<void> Sha512::write(BytesIn data) {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (1 != SHA512_Update(&ctx_, data.data(), data.size())) {
Expand All @@ -31,7 +31,7 @@ namespace libp2p::crypto {
}

outcome::result<void> Sha512::digestOut(BytesOut out) const {
if (not initialized_) {
if (!initialized_) {
return HmacProviderError::FAILED_INITIALIZE_CONTEXT;
}
if (out.size() != digestSize()) {
Expand Down
2 changes: 1 addition & 1 deletion src/host/basic_host/basic_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace libp2p::host {
}
}
}
if (not is_good_addr) {
if (!is_good_addr) {
i = unique_addresses.erase(i);
} else {
++i;
Expand Down
2 changes: 1 addition & 1 deletion src/layer/websocket/ws_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace libp2p::connection {
}

void WsConnection::stop() {
if (not started_) {
if (!started_) {
log_->error("already stopped (double stop)");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/layer/websocket/wss_adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace libp2p::layer {
void WssAdaptor::upgradeInbound(
std::shared_ptr<connection::LayerConnection> 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<connection::SslConnection>(
Expand Down
2 changes: 1 addition & 1 deletion src/multi/converters/converter_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace libp2p::multi::converters {
};
auto uvar = [&]() -> outcome::result<uint64_t> {
auto var = UVarint::create(bytes);
if (not var) {
if (!var) {
return ConversionError::INVALID_ADDRESS;
}
bytes = bytes.subspan(var->size());
Expand Down
2 changes: 1 addition & 1 deletion src/multi/multiaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/muxer/mplex/mplex_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace libp2p::connection {
std::lock_guard<std::mutex> 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);
Expand Down
12 changes: 6 additions & 6 deletions src/muxer/yamux/yamuxed_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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<StreamId> abandoned;
Expand All @@ -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_);
}
Expand Down
Loading
Loading