Skip to content

Commit 5e710cf

Browse files
committed
formatting
1 parent ec231d5 commit 5e710cf

File tree

5 files changed

+50
-42
lines changed

5 files changed

+50
-42
lines changed

llarp/consensus/reachability_testing.cpp

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,35 +80,40 @@ namespace llarp::consensus
8080
}
8181

8282
auto [conn, btstr] = router.link_endpoint().testing_client_connect(*rc);
83-
btstr->command("ping", "", TEST_REQUEST_TIMEOUT, [this, weak_conn = std::weak_ptr{conn}, rid, prev_fails](quic::message m) mutable {
84-
auto conn = weak_conn.lock();
85-
if (conn)
86-
conn->close_connection();
87-
router.loop.call_soon([this, rid, prev_fails, m = std::move(m)] {
88-
if (m)
89-
{
90-
if (prev_fails)
83+
btstr->command(
84+
"ping",
85+
"",
86+
TEST_REQUEST_TIMEOUT,
87+
[this, weak_conn = std::weak_ptr{conn}, rid, prev_fails](quic::message m) mutable {
88+
auto conn = weak_conn.lock();
89+
if (conn)
90+
conn->close_connection();
91+
router.loop.call_soon([this, rid, prev_fails, m = std::move(m)] {
92+
if (m)
93+
{
94+
if (prev_fails)
95+
log::info(
96+
logcat,
97+
"Successful SN reachability test to {} (after {} previous failures)",
98+
rid.to_network_address(true),
99+
prev_fails);
100+
else
101+
log::info(
102+
logcat, "Successful SN reachability test to {}", rid.to_network_address(true));
103+
remove_node_from_failing(rid);
104+
}
105+
else
106+
{
91107
log::info(
92108
logcat,
93-
"Successful SN reachability test to {} (after {} previous failures)",
109+
"Testing of {} failed: {}",
94110
rid.to_network_address(true),
95-
prev_fails);
96-
else
97-
log::info(logcat, "Successful SN reachability test to {}", rid.to_network_address(true));
98-
remove_node_from_failing(rid);
99-
}
100-
else
101-
{
102-
log::info(
103-
logcat,
104-
"Testing of {} failed: {}",
105-
rid.to_network_address(true),
106-
m.timed_out ? "request timed out" : m.body());
107-
add_failing_node(rid, prev_fails);
108-
}
109-
router.oxend()->inform_connection(rid, (bool)m);
111+
m.timed_out ? "request timed out" : m.body());
112+
add_failing_node(rid, prev_fails);
113+
}
114+
router.oxend()->inform_connection(rid, (bool)m);
115+
});
110116
});
111-
});
112117
}
113118
}
114119

llarp/contact/contactdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace llarp
2020

2121
void ContactDB::start_tickers()
2222
{
23-
_purge_ticker = _router.loop.call_every(30s, [this](){ purge_ccs(); }, true);
23+
_purge_ticker = _router.loop.call_every(30s, [this]() { purge_ccs(); }, true);
2424
}
2525

2626
void ContactDB::purge_ccs(std::chrono::milliseconds now)

llarp/crypto/key_manager.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace llarp
2222
oxenc::from_hex(tmp.begin(), tmp.begin() + 128, key.data());
2323
else if (tmp.size() == 64)
2424
std::memcpy(key.data(), tmp.data(), 64);
25-
else if (tmp.starts_with('d') and tmp.ends_with('e')) {
25+
else if (tmp.starts_with('d') and tmp.ends_with('e'))
26+
{
2627
// Old Lokinet keys were bt-dicts with the key we care about in the 's' key:
2728
oxenc::bt_dict_consumer old{tmp};
2829
auto oldkey = old.require_span<unsigned char, 64>("s");
@@ -31,7 +32,8 @@ namespace llarp
3132
}
3233
else
3334
throw std::invalid_argument{
34-
"Invalid key file {} ({}B): Expected 64 bytes, 128 hex, or legacy lokinet key file"_format(fname, tmp.size())};
35+
"Invalid key file {} ({}B): Expected 64 bytes, 128 hex, or legacy lokinet key file"_format(
36+
fname, tmp.size())};
3537

3638
if (!key.check_pubkey())
3739
throw std::invalid_argument{"Invalid key file {}: Keypair seed and pubkey do not match"};

llarp/path/path_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ namespace llarp::path
651651
std::chrono::seconds lifetime{
652652
oxenc::load_little_to_host<uint32_t>(inner.require_span<std::byte, sizeof(uint32_t)>("l").data())};
653653
if (lifetime > path::MAX_LIFETIME_ACCEPTED)
654-
throw std::runtime_error{
655-
"Path lifetime {} exceeds maximum allowed path lifetime {}"_format(lifetime, path::MAX_LIFETIME_ACCEPTED)};
654+
throw std::runtime_error{"Path lifetime {} exceeds maximum allowed path lifetime {}"_format(
655+
lifetime, path::MAX_LIFETIME_ACCEPTED)};
656656
hop.expiry = now + lifetime;
657657
hop.rxid.assign(inner.require_span<std::byte, HopID::SIZE>("r"));
658658
hop.txid.assign(inner.require_span<std::byte, HopID::SIZE>("t"));

llarp/session/session.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace llarp::session
106106
}};
107107

108108
auto stream_opened = [this](quic::Stream& stream) {
109-
/*
109+
#if 0
110110
stream.set_stream_data_cb([this, prev_byte = std::optional<std::byte>{std::nullopt}](
111111
quic::Stream& stream, std::span<const std::byte> data) mutable {
112112
uint16_t dest_port{0};
@@ -163,7 +163,7 @@ namespace llarp::session
163163
50'000,
164164
[this, tcp_conn](auto&) { tcp_conn->resume_reading(); });
165165
});
166-
*/
166+
#endif
167167
return 0;
168168
};
169169

@@ -817,10 +817,7 @@ namespace llarp::session
817817
}
818818
}
819819

820-
void Session::recv_close()
821-
{
822-
_parent.close_session(_inbound_tag, false);
823-
}
820+
void Session::recv_close() { _parent.close_session(_inbound_tag, false); }
824821

825822
void OutboundRelaySession::recv_close()
826823
{
@@ -1185,7 +1182,10 @@ namespace llarp::session
11851182
_remote.router_id(), [this, alive = canary()](std::optional<ClientContact> cc) mutable {
11861183
if (!alive.lock())
11871184
{
1188-
log::debug(logcat, "OutboundClientSession::refresh_intros lookup_client_intro callback returning early; session-alive canary is dead");
1185+
log::debug(
1186+
logcat,
1187+
"OutboundClientSession::refresh_intros lookup_client_intro callback returning early; "
1188+
"session-alive canary is dead");
11891189
return;
11901190
}
11911191
updating_intros = false;
@@ -1205,7 +1205,7 @@ namespace llarp::session
12051205
{
12061206
log::debug(logcat, "Update session {} intros from client contact: {}", *this, cc);
12071207
last_cc_update = llarp::time_now_ms();
1208-
last_inbound_activity = last_cc_update; // so we don't just fetch again right away
1208+
last_inbound_activity = last_cc_update; // so we don't just fetch again right away
12091209
auto intros = cc.intros();
12101210
_intros.assign(intros.begin(), intros.end());
12111211
log::trace(logcat, "New client intros: {}", fmt::join(_intros, ", "));
@@ -1396,15 +1396,15 @@ namespace llarp::session
13961396
return;
13971397
}
13981398
auto& m = maybe_path_switch_msg->first;
1399-
m.resize(m.size() - (sizeof(session_tag) + HopID::SIZE)); // these go on outer message here
1399+
m.resize(m.size() - (sizeof(session_tag) + HopID::SIZE)); // these go on outer message here
14001400

14011401
oxenc::bt_list_producer btlp;
14021402
btlp.append(std::move((*maybe_path_switch_msg).first));
14031403
btlp.append(std::move(session_init_msg));
14041404
auto list_span = btlp.span<std::byte>();
14051405
std::vector<std::byte> payload{list_span.begin(), list_span.end()};
14061406
auto old_size = payload.size();
1407-
payload.resize(payload.size() + sizeof(_outbound_tag) + HopID::SIZE); // see make_session_data_message
1407+
payload.resize(payload.size() + sizeof(_outbound_tag) + HopID::SIZE); // see make_session_data_message
14081408
auto [payload_span, tag_span, pivot_span] = split_span(payload, old_size, sizeof(_outbound_tag));
14091409
oxenc::write_host_as_big(_outbound_tag, tag_span.data());
14101410
std::memcpy(pivot_span.data(), _remote_pivot_txid.data(), _remote_pivot_txid.size());
@@ -1572,13 +1572,14 @@ namespace llarp::session
15721572
"Received session accept message for established session, likely a path switch failed because the "
15731573
"remote restarted, so it accepted our backup session init.");
15741574
}
1575-
_is_established = false; // become unestablished if this parsing fails to trigger a new session init
1575+
_is_established = false; // become unestablished if this parsing fails to trigger a new session init
15761576
oxenc::bt_dict_consumer btdc{params};
15771577
_outbound_tag = btdc.require<session_tag>("t"sv);
15781578

15791579
log::debug(logcat, "Remote provided session tag: {}", _outbound_tag);
15801580

1581-
log::trace(logcat, "Outbound session to {} successfully {}established.", remote(), was_established ? "re-"sv : ""sv);
1581+
log::trace(
1582+
logcat, "Outbound session to {} successfully {}established.", remote(), was_established ? "re-"sv : ""sv);
15821583
_is_established = true;
15831584

15841585
if (pre_establish_data_queue)

0 commit comments

Comments
 (0)