build: raise LXMF host minimum to Rust 1.89

This commit is contained in:
DeFiDude committed 2026-10-08 22:59:46 -06:00
1 parent 284d56fee3
commit e38d30e02a
19 files changed
+283 -334

No files matched your search

+3 -3
View File
@@ -10,7 +10,7 @@ permissions:
contents: read
env:
RSLXMF_RSRETICULUM_COMMIT: 5edb8f22f5d8e6b2bd7392dc06e255ead96576fb
RSLXMF_RSRETICULUM_COMMIT: cac8151fd8207ada9775310fe2b3c9c7340a7ecd
jobs:
api-compat:
@@ -119,7 +119,7 @@ jobs:
working-directory: rsLXMF
msrv:
name: Rust 1.87 MSRV
name: Rust 1.89 MSRV
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
@@ -133,7 +133,7 @@ jobs:
path: rsReticulum
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.87.0
toolchain: 1.89.0
components: clippy
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
+2 -2
View File
@@ -38,7 +38,7 @@ jobs:
path: rsReticulum
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.87.0
toolchain: 1.89.0
- name: Verify release source and dependency
working-directory: rsLXMF
run: python3 scripts/ci/check_source_release_contract.py --release-tag "${RELEASE_TAG}"
@@ -75,7 +75,7 @@ jobs:
path: rsReticulum
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.87.0
toolchain: 1.89.0
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
workspaces: rsLXMF -> target
+2
View File
@@ -15,6 +15,8 @@
### Build and compatibility
- Raised the host source-build minimum to Rust 1.89 and qualified the corresponding protocol dependency update.
- Restricted rsReticulum compatibility to the 1.3 patch line so a later breaking minor release requires an explicit update.
- Updated the Python interoperability baseline to Reticulum 1.4.2 and LXMF 1.0.1, with separate LXMF 1.1.0 checks.
+1 -1
View File
@@ -9,7 +9,7 @@ members = [
version = "1.2.0"
edition = "2024"
license = "AGPL-3.0-or-later"
rust-version = "1.87"
rust-version = "1.89"
[workspace.dependencies]
# Reticulum crates from a sibling rsReticulum checkout during development.
+1 -1
View File
@@ -5,7 +5,7 @@
**Rust LXMF messaging and propagation for Reticulum.**
[![License: AGPL-3.0-or-later](https://img.shields.io/badge/license-AGPL--3.0--or--later-blue.svg)](LICENSE)
[![Rust 1.87+](https://img.shields.io/badge/rust-1.87%2B-orange.svg)](https://www.rust-lang.org)
[![Rust 1.89+](https://img.shields.io/badge/rust-1.89%2B-orange.svg)](https://www.rust-lang.org)
[![Compatibility floor: LXMF 1.0.1](https://img.shields.io/badge/compatibility%20floor-LXMF%201.0.1-success.svg)](https://github.com/markqvist/LXMF)
[![Current reference: LXMF 1.1.0](https://img.shields.io/badge/current%20reference-LXMF%201.1.0-blue.svg)](https://github.com/markqvist/LXMF)
[![Status](https://img.shields.io/badge/status-experimental-yellow.svg)](#feature-status)
+2 -2
View File
@@ -5,7 +5,7 @@
{
"name": "lxmf-core",
"version": "1.2.0",
"rustVersion": "1.87",
"rustVersion": "1.89",
"edition": "2024",
"features": {},
"targets": [
@@ -239,7 +239,7 @@
{
"name": "lxmf-tools",
"version": "1.2.0",
"rustVersion": "1.87",
"rustVersion": "1.89",
"edition": "2024",
"features": {},
"targets": [
+1 -1
View File
@@ -1,2 +1,2 @@
# Keep Clippy suggestions aligned with the public MSRV in Cargo.toml.
msrv = "1.87"
msrv = "1.89"
+12 -12
View File
@@ -159,15 +159,16 @@ impl DeliveryRatchetState {
}
}
if control_file_trusted && (!control_existed || control_changed) {
if let Err(error) = control.save_verified(&control_path, identity) {
if control_file_trusted
&& (!control_existed || control_changed)
&& let Err(error) = control.save_verified(&control_path, identity)
{
tracing::warn!(
path = %control_path.display(),
%error,
"could not persist initial ratchet control state; new announces remain deferred until persistence recovers"
);
}
}
Ok(Self {
destination,
@@ -210,14 +211,13 @@ impl DeliveryRatchetState {
}
let announce_time = AnnounceTime::new(wall_now, cache_now)?;
if let DeliveryAnnounceKind::PathResponse { tag: Some(tag) } = kind {
if let Some(packet) = self
if let DeliveryAnnounceKind::PathResponse { tag: Some(tag) } = kind
&& let Some(packet) = self
.destination
.cached_path_response_packet(tag, cache_now)?
{
return Ok(packet);
}
}
if !self.control_file_trusted {
return Err(DeliveryRatchetError::UntrustedControl {
@@ -292,17 +292,17 @@ impl DeliveryRatchetState {
/// Best-effort shutdown checkpoint. Invalid files detected during load are
/// never overwritten by this operation.
pub fn save(&self, identity: &Identity) {
if self.ring_file_trusted {
if let Err(error) = self.ring.save_verified(&self.ring_path, identity) {
if self.ring_file_trusted
&& let Err(error) = self.ring.save_verified(&self.ring_path, identity)
{
tracing::warn!(%error, "failed to save ratchet ring");
}
}
if self.control_file_trusted {
if let Err(error) = self.control.save_verified(&self.control_path, identity) {
if self.control_file_trusted
&& let Err(error) = self.control.save_verified(&self.control_path, identity)
{
tracing::warn!(%error, "failed to save ratchet control state");
}
}
}
pub fn ring_path(&self) -> &Path {
&self.ring_path
+44 -53
View File
@@ -187,11 +187,11 @@ impl<T> From<oneshot::Receiver<T>> for ReadyReceipt<T> {
}
impl<T> ReadyReceipt<T> {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> bool {
if self.ready.is_none() {
if let Poll::Ready(result) = Pin::new(&mut self.receiver).poll(cx) {
if self.ready.is_none()
&& let Poll::Ready(result) = Pin::new(&mut self.receiver).poll(cx)
{
self.ready = Some(result);
}
}
self.ready.is_some()
}
fn try_recv(&mut self) -> Result<T, oneshot::error::TryRecvError> {
@@ -907,16 +907,16 @@ impl LinkDeliveryManager {
/// Use one polling task per manager and retain periodic ticks for protocol
/// deadlines. A bounded drain may leave more input ready for the next turn.
pub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<()> {
if self.ready_event.is_none() {
if let Poll::Ready(event) = self.event_rx.poll_recv(cx) {
if self.ready_event.is_none()
&& let Poll::Ready(event) = self.event_rx.poll_recv(cx)
{
self.ready_event = event;
}
}
if self.ready_lifecycle.is_none() {
if let Poll::Ready(event) = self.endpoint_lifecycle_rx.poll_recv(cx) {
if self.ready_lifecycle.is_none()
&& let Poll::Ready(event) = self.endpoint_lifecycle_rx.poll_recv(cx)
{
self.ready_lifecycle = event;
}
}
let mut ready = self.ready_event.is_some() || self.ready_lifecycle.is_some();
for pending in self.pending_endpoint_binds.values_mut() {
ready |= pending.result_rx.poll_ready(cx);
@@ -1844,12 +1844,12 @@ impl LinkDeliveryManager {
if event.binding.role != LinkEndpointRole::Initiator {
continue;
}
if let Some(delivery) = self.pending.get_mut(&event.binding.link_id) {
if delivery.attached_interface == Some(event.binding.interface_id)
if let Some(delivery) = self.pending.get_mut(&event.binding.link_id)
&& (delivery.attached_interface == Some(event.binding.interface_id)
|| self
.pending_endpoint_binds
.get(&event.binding.link_id)
.is_some_and(|pending| pending.interface_id == event.binding.interface_id)
.is_some_and(|pending| pending.interface_id == event.binding.interface_id))
{
tracing::warn!(
link_id = %hex_encode(&event.binding.link_id),
@@ -1865,7 +1865,6 @@ impl LinkDeliveryManager {
self.pending_endpoint_binds.remove(&event.binding.link_id);
}
}
}
let link_ids: Vec<[u8; 16]> = self.pending_endpoint_binds.keys().copied().collect();
for link_id in link_ids {
@@ -2109,12 +2108,12 @@ impl LinkDeliveryManager {
}
rns_wire::context::PacketContext::ResourceHmu => {
let plaintext = self.decrypt_resource_control(&link_id, data);
if let Some(pt) = plaintext {
if !self.handle_inbound_resource_hmu(&link_id, &pt) {
if let Some(pt) = plaintext
&& !self.handle_inbound_resource_hmu(&link_id, &pt)
{
self.handle_hmu(&link_id, &pt);
}
}
}
rns_wire::context::PacketContext::ResourceReq => {
// Python `Resource.request_next` may arrive before any HMU and be the
// only signal to advance the transfer, so drive it here directly.
@@ -2852,20 +2851,18 @@ impl LinkDeliveryManager {
{
continue;
}
if !delivery.reusable && !delivery.pretransfer_identify_staged {
if let (Some(pub_key), Some(sign_key)) =
if !delivery.reusable
&& !delivery.pretransfer_identify_staged
&& let (Some(pub_key), Some(sign_key)) =
(&self.identity_pub, &self.identity_key)
{
if let Ok(identify_data) = delivery.link.identify(pub_key, sign_key)
&& let Ok(identify_data) = delivery.link.identify(pub_key, sign_key)
{
let id_header = rns_wire::header::PacketHeader {
flags: rns_wire::flags::PacketFlags {
header_type: rns_wire::flags::HeaderType::Header1,
context_flag: false,
transport_type:
rns_wire::flags::TransportType::Broadcast,
destination_type:
rns_wire::flags::DestinationType::Link,
transport_type: rns_wire::flags::TransportType::Broadcast,
destination_type: rns_wire::flags::DestinationType::Link,
packet_type: rns_wire::flags::PacketType::Data,
},
hops: 0,
@@ -2895,8 +2892,6 @@ impl LinkDeliveryManager {
continue;
}
}
}
}
// Reusable Direct links follow upstream LXMF and identify
// after a successful delivery, not before the transfer.
// One-shot propagation links keep the previous pre-transfer
@@ -3375,12 +3370,12 @@ impl LinkDeliveryManager {
) {
results.push(result);
}
} else if proof_observed {
if let Some(result) = self.complete_backchannel_delivery(key) {
} else if proof_observed
&& let Some(result) = self.complete_backchannel_delivery(key)
{
results.push(result);
}
}
}
Ok(Err(err)) => {
let reason = err.to_string();
if start.cancelled {
@@ -3527,11 +3522,11 @@ impl LinkDeliveryManager {
if let Some(ref mut transfer) = delivery.transfer {
transfer.handle_hmu(hmu_data);
let progress = delivery_resource_progress(delivery);
if let Some(progress) = progress {
if should_update_resource_progress(delivery.message.progress, progress) {
if let Some(progress) = progress
&& should_update_resource_progress(delivery.message.progress, progress)
{
delivery.message.progress = progress;
}
}
progress.map(|_| {
delivery_event(
LxmfDeliveryEventKind::TransferProgress,
@@ -3610,11 +3605,11 @@ impl LinkDeliveryManager {
}
}
let progress = delivery_resource_progress(delivery);
if let Some(progress) = progress {
if should_update_resource_progress(delivery.message.progress, progress) {
if let Some(progress) = progress
&& should_update_resource_progress(delivery.message.progress, progress)
{
delivery.message.progress = progress;
}
}
progress.map(|_| {
delivery_event(
LxmfDeliveryEventKind::TransferProgress,
@@ -3701,9 +3696,10 @@ impl LinkDeliveryManager {
let mut rejected_hash = [0u8; 32];
rejected_hash.copy_from_slice(&reject_data[..32]);
if let Some(delivery) = self.pending.get_mut(link_id) {
if let Some(ref mut transfer) = delivery.transfer {
if transfer.resource.resource_hash == rejected_hash {
if let Some(delivery) = self.pending.get_mut(link_id)
&& let Some(ref mut transfer) = delivery.transfer
&& transfer.resource.resource_hash == rejected_hash
{
transfer.handle_cancel();
delivery.remaining_segments = None;
delivery.message.mark_rejected();
@@ -3711,8 +3707,6 @@ impl LinkDeliveryManager {
delivery.failure_reason = Some("resource rejected".to_string());
return true;
}
}
}
false
}
@@ -3762,10 +3756,10 @@ impl LinkDeliveryManager {
/// Apply an inbound link-packet proof; returns `true` when the packet delivery is complete.
pub fn handle_link_packet_proof(&mut self, link_id: &[u8; 16], proof_data: &[u8]) -> bool {
if let Some(delivery) = self.pending.get_mut(link_id) {
if delivery.state == DeliveryState::AwaitingProof {
if let Some(packet_hash) = delivery.packet_proof_hash {
if delivery
if let Some(delivery) = self.pending.get_mut(link_id)
&& delivery.state == DeliveryState::AwaitingProof
&& let Some(packet_hash) = delivery.packet_proof_hash
&& delivery
.link
.validate_packet_proof(&packet_hash, proof_data)
{
@@ -3774,9 +3768,6 @@ impl LinkDeliveryManager {
delivery.state = DeliveryState::Complete;
return true;
}
}
}
}
false
}
@@ -4268,8 +4259,9 @@ impl LinkDeliveryManager {
.pending_backchannel_deliveries
.iter()
.find_map(|(key, delivery)| (delivery.message.hash == Some(msg_hash)).then_some(*key));
if let Some(key) = pending_key {
if let Some(delivery) = self.pending_backchannel_deliveries.remove(&key) {
if let Some(key) = pending_key
&& let Some(delivery) = self.pending_backchannel_deliveries.remove(&key)
{
self.remove_backchannel_owner(delivery.dest_hash, delivery.link_id);
self.cancel_backchannel_packet_key(key, delivery.packet_cancellation);
if let BackchannelProofKey::Resource(link_id, resource_hash) = key {
@@ -4301,7 +4293,6 @@ impl LinkDeliveryManager {
reason: reason.to_string(),
});
}
}
results
}
@@ -4965,8 +4956,9 @@ fn finish_reusable_delivery(
link_id: &[u8; 16],
delivery: &mut PendingDelivery,
) {
if !delivery.backchannel_identified {
if let (Some(pub_key), Some(sign_key)) = (identity_pub, identity_key) {
if !delivery.backchannel_identified
&& let (Some(pub_key), Some(sign_key)) = (identity_pub, identity_key)
{
delivery.backchannel_identified = send_link_identify(
transport_tx,
pending_transport,
@@ -4977,7 +4969,6 @@ fn finish_reusable_delivery(
sign_key,
);
}
}
delivery.transfer = None;
delivery.remaining_segments = None;
+5 -6
View File
@@ -606,8 +606,9 @@ impl LxMessage {
self.transient_id = Some(tid);
let mut stamp_value = 0;
if let Some(target_cost) = propagation_stamp_cost {
if self.propagation_stamp.is_none() {
if let Some(target_cost) = propagation_stamp_cost
&& self.propagation_stamp.is_none()
{
let (stamp, value) = crate::stamper::generate_stamp(
&tid,
target_cost,
@@ -619,7 +620,6 @@ impl LxMessage {
self.propagation_stamp = Some(stamp);
stamp_value = value;
}
}
if let Some(ref prop_stamp) = self.propagation_stamp {
if stamp_value == 0 {
@@ -1008,15 +1008,14 @@ impl LxMessage {
// 4. Generate PoW stamp
let cost = self.stamp_cost.unwrap();
if let Some(message_id) = self.message_id {
if let Some((stamp, value)) =
if let Some(message_id) = self.message_id
&& let Some((stamp, value)) =
crate::stamper::generate_stamp(&message_id, cost, STAMP_WORKBLOCK_EXPAND_ROUNDS)
{
self.stamp_value = Some(value as u16);
self.stamp = Some(stamp.to_vec());
return Some(stamp.to_vec());
}
}
None
}
+4 -3
View File
@@ -68,15 +68,16 @@ pub fn write_file_atomic(path: &Path, data: &[u8]) -> io::Result<()> {
fs::rename(&tmp, path)
})();
if result.is_err() && tmp.exists() {
if let Err(e) = fs::remove_file(&tmp) {
if result.is_err()
&& tmp.exists()
&& let Err(e) = fs::remove_file(&tmp)
{
tracing::error!(
"Error while cleaning temporary file {} for {}: {e}",
tmp.display(),
path.display()
);
}
}
result
}
+20 -23
View File
@@ -620,13 +620,13 @@ impl PropagationClient {
continue;
}
let node_hex = self.outbound_propagation_node.map(|h| hex_encode(&h));
if let Some(node_hex) = node_hex {
if let Some(pub_key) = known_identities.get(&node_hex) {
if let Some(node_hex) = node_hex
&& let Some(pub_key) = known_identities.get(&node_hex)
{
let ed25519_bytes: [u8; 32] = pub_key[32..64]
.try_into()
.expect("known_identities values are [u8; 64]; slice [32..64] is always 32 bytes");
if let Ok(verify_key) =
Ed25519PublicKey::from_bytes(&ed25519_bytes)
if let Ok(verify_key) = Ed25519PublicKey::from_bytes(&ed25519_bytes)
{
self.handle_link_proof(
data,
@@ -637,15 +637,13 @@ impl PropagationClient {
}
}
}
}
rns_wire::context::PacketContext::Response => {
if let Some(ref mut link) = self.link {
if let Ok((_request_id, response_data)) = link.handle_response(data)
if let Some(ref mut link) = self.link
&& let Ok((_request_id, response_data)) = link.handle_response(data)
{
self.handle_response_data(&response_data);
}
}
}
rns_wire::context::PacketContext::ResourceAdv => {
self.handle_resource_advertisement(data);
}
@@ -709,8 +707,9 @@ impl PropagationClient {
None => return,
};
if let Ok(rtt_data) = link.validate_proof(proof_data, verify_key, ed25519_pub) {
if let Some(link_id) = self.link_id {
if let Ok(rtt_data) = link.validate_proof(proof_data, verify_key, ed25519_pub)
&& let Some(link_id) = self.link_id
{
let rtt_header = rns_wire::header::PacketHeader {
flags: rns_wire::flags::PacketFlags {
header_type: rns_wire::flags::HeaderType::Header1,
@@ -751,7 +750,6 @@ impl PropagationClient {
});
}
}
}
fn handle_response_data(&mut self, response_data: &[u8]) {
let response_phase = if self.status.state == PropagationClientState::Receiving {
@@ -1206,12 +1204,12 @@ impl PropagationClient {
if let Some(arr) = value.as_array() {
self.available_messages.clear();
for item in arr {
if let Some(id_bytes) = item.as_slice() {
if id_bytes.len() == 32 {
if let Some(id_bytes) = item.as_slice()
&& id_bytes.len() == 32
{
self.available_messages.push(id_bytes.to_vec());
}
}
}
if self.available_messages.is_empty() {
self.status.state = PropagationClientState::Complete;
@@ -1272,8 +1270,8 @@ impl PropagationClient {
return;
}
if let Some(started) = self.started_at {
if started.elapsed() > self.timeout
if let Some(started) = self.started_at
&& started.elapsed() > self.timeout
&& matches!(
self.status.state,
PropagationClientState::LinkEstablishing
@@ -1286,7 +1284,6 @@ impl PropagationClient {
self.status.state = PropagationClientState::Failed;
return;
}
}
let link_action = self.link.as_mut().map(Link::tick);
match link_action {
@@ -1384,12 +1381,12 @@ impl PropagationClient {
} else {
None
};
if let Some(outbound) = outbound {
if !self.queue_link_endpoint(outbound) {
if let Some(outbound) = outbound
&& !self.queue_link_endpoint(outbound)
{
self.status.state = PropagationClientState::Failed;
}
}
}
/// Phase 1: `/get` with `[None, None]`.
fn send_list_request(&mut self) {
@@ -1539,11 +1536,11 @@ impl PropagationClient {
fn cleanup(&mut self) {
let graceful_release = self.endpoint_release_queued || self.send_teardown();
if let Some(link_id) = self.link_id.take() {
if !graceful_release {
if let Some(link_id) = self.link_id.take()
&& !graceful_release
{
self.queue_endpoint_cleanup(link_id);
}
}
self.attached_interface = None;
self.endpoint_release_queued = false;
self.pending_endpoint_bind = None;
+17 -21
View File
@@ -254,13 +254,12 @@ pub(crate) fn prepare_sync_offer_snapshot(
.propagation_sync_limit
.map(kilobytes_to_bytes_fail_closed);
let mut handled_messages = snapshot.policy.handled_messages.clone();
if let Some(path) = snapshot.peer_path.as_ref() {
if let Ok(data) = std::fs::read(path) {
if let Some(peer) = LxmPeer::from_bytes_with_handled(&data) {
if let Some(path) = snapshot.peer_path.as_ref()
&& let Ok(data) = std::fs::read(path)
&& let Some(peer) = LxmPeer::from_bytes_with_handled(&data)
{
handled_messages.extend(peer.handled_messages);
}
}
}
let mut candidates = snapshot.candidates;
candidates.sort_by(|left, right| {
@@ -792,12 +791,12 @@ impl PropagationNode {
self.advance_offer_generation();
}
if before > after {
if let Some(ref dir) = self.storage_path {
if before > after
&& let Some(ref dir) = self.storage_path
{
self.cleanup_orphaned_files(dir);
}
}
}
fn cleanup_orphaned_files(&self, dir: &std::path::Path) {
if let Ok(entries) = std::fs::read_dir(dir) {
@@ -813,14 +812,14 @@ impl PropagationNode {
if filename.ends_with(".peer") || filename.ends_with(".msgpack") {
continue;
}
if let Some((tid, _, _)) = PropagationEntry::parse_filename(&filename) {
if !self.store.contains(&tid) {
if let Some((tid, _, _)) = PropagationEntry::parse_filename(&filename)
&& !self.store.contains(&tid)
{
let _ = std::fs::remove_file(&path);
}
}
}
}
}
/// When `peer_min_stamp_cost` is `Some`, include only messages whose stamp
/// value meets the peer's threshold, so we don't send messages the peer
@@ -1116,8 +1115,8 @@ impl PropagationNode {
for want_val in wants_arr {
if let (Some(tid), Some(dir)) =
(parse_store_id(want_val), self.storage_path.as_ref())
&& let Some(entry) = self.store.get(&tid)
{
if let Some(entry) = self.store.get(&tid) {
// Ownership gate (Python LXMRouter.py:1479): a client
// may only download messages addressed to itself.
if entry.destination_hash == *client_dest_hash {
@@ -1129,7 +1128,6 @@ impl PropagationNode {
}
}
}
}
// Wire value is decimal kilobytes (Python LXMRouter.py:1471).
let limit_bytes = if arr.len() > 2 {
@@ -1288,12 +1286,11 @@ impl PropagationNode {
// Compatibility wrapper: production uses the staged task
// path and exposes this delta to the daemon for off-loop
// persistence.
if !terminal_handled_ids.is_empty() {
if let Err(error) = self.persist_peer_handled(policy, &terminal_handled_ids)
if !terminal_handled_ids.is_empty()
&& let Err(error) = self.persist_peer_handled(policy, &terminal_handled_ids)
{
tracing::warn!(%error, "failed to persist terminal offer dispositions");
}
}
return offer;
}
InstallPreparedSyncOffer::Stale => continue,
@@ -1406,16 +1403,15 @@ impl PropagationNode {
if let Ok(entries) = std::fs::read_dir(dir) {
for entry in entries.flatten() {
let path = entry.path();
if path.extension().map(|e| e == "peer").unwrap_or(false) {
if let Ok(data) = std::fs::read(&path) {
if let Some(mut peer) = LxmPeer::from_bytes_with_handled(&data) {
if path.extension().map(|e| e == "peer").unwrap_or(false)
&& let Ok(data) = std::fs::read(&path)
&& let Some(mut peer) = LxmPeer::from_bytes_with_handled(&data)
{
self.prune_handled_against_store(&mut peer);
peers.push(peer);
}
}
}
}
}
peers
}
+29 -37
View File
@@ -718,12 +718,11 @@ impl PropagationSyncTask {
continue;
}
let node_hex = self.node_dest_hash.map(|h| hex_encode(&h));
if let Some(node_hex) = node_hex {
if let Some(pub_key) = known_identities.get(&node_hex) {
let ed25519_bytes: [u8; 32] =
pub_key[32..64].try_into().unwrap();
if let Ok(verify_key) =
Ed25519PublicKey::from_bytes(&ed25519_bytes)
if let Some(node_hex) = node_hex
&& let Some(pub_key) = known_identities.get(&node_hex)
{
let ed25519_bytes: [u8; 32] = pub_key[32..64].try_into().unwrap();
if let Ok(verify_key) = Ed25519PublicKey::from_bytes(&ed25519_bytes)
{
self.handle_link_proof(
data,
@@ -734,16 +733,14 @@ impl PropagationSyncTask {
}
}
}
}
rns_wire::context::PacketContext::ResourceHmu => {
if let Some(ref link) = self.link {
if let Ok(plaintext) = link.decrypt(data) {
if let Some(ref mut transfer) = self.active_transfer {
if let Some(ref link) = self.link
&& let Ok(plaintext) = link.decrypt(data)
&& let Some(ref mut transfer) = self.active_transfer
{
transfer.handle_hmu(&plaintext);
}
}
}
}
rns_wire::context::PacketContext::ResourceReq => {
self.handle_resource_request(data);
}
@@ -760,18 +757,14 @@ impl PropagationSyncTask {
}
}
rns_wire::context::PacketContext::Response => {
if self.state == SyncTaskState::AwaitingResponse {
if let Some(ref mut link) = self.link {
if let Ok((_request_id, response_data)) =
link.handle_response(data)
if self.state == SyncTaskState::AwaitingResponse
&& let Some(ref mut link) = self.link
&& let Ok((_request_id, response_data)) = link.handle_response(data)
{
let offer_response =
OfferResponse::from_msgpack(&response_data);
let offer_response = OfferResponse::from_msgpack(&response_data);
self.handle_offer_response(offer_response);
}
}
}
}
rns_wire::context::PacketContext::ResourceRcl
| rns_wire::context::PacketContext::ResourceIcl => {
self.handle_resource_cancel(data);
@@ -1039,11 +1032,11 @@ impl PropagationSyncTask {
fn prepare_transfer_for_ids(&mut self, ids: &[PropagationTransientId]) {
if ids.is_empty() {
if let Some(node_hash) = self.node_dest_hash {
if let Ok(mut node) = self.propagation_node.lock() {
if let Some(node_hash) = self.node_dest_hash
&& let Ok(mut node) = self.propagation_node.lock()
{
node.complete_sync(&node_hash);
}
}
self.state = SyncTaskState::Complete;
return;
}
@@ -1128,8 +1121,8 @@ impl PropagationSyncTask {
if self.terminal_result.is_none()
&& self.offer_policy.is_none()
&& self.last_sync.elapsed() >= self.sync_interval
&& let Some(node_hash) = self.node_dest_hash
{
if let Some(node_hash) = self.node_dest_hash {
if self.message_count() > 0 {
let _ = self.start_sync(node_hash);
} else {
@@ -1137,7 +1130,6 @@ impl PropagationSyncTask {
}
}
}
}
SyncTaskState::Establishing | SyncTaskState::AwaitingResponse => {}
SyncTaskState::Offering => {
self.send_offer_request();
@@ -1146,8 +1138,9 @@ impl PropagationSyncTask {
self.drive_transfers();
}
SyncTaskState::Complete | SyncTaskState::Failed => {
if self.terminal_result.is_none() {
if let Some(peer_hash) = self.node_dest_hash {
if self.terminal_result.is_none()
&& let Some(peer_hash) = self.node_dest_hash
{
let complete = self.state == SyncTaskState::Complete;
self.terminal_result = Some(PeerSyncTerminalResult {
peer_hash,
@@ -1178,7 +1171,6 @@ impl PropagationSyncTask {
.flatten(),
});
}
}
self.cleanup_sync();
self.last_sync = Instant::now();
self.state = SyncTaskState::Idle;
@@ -1311,11 +1303,11 @@ impl PropagationSyncTask {
self.active_offer_generation = Some(generation);
self.generation_exhausted = generation_exhausted;
self.record_handled_updates(&terminal_handled_ids);
if offer.transient_ids.is_empty() {
if let Ok(mut node) = self.propagation_node.lock() {
if offer.transient_ids.is_empty()
&& let Ok(mut node) = self.propagation_node.lock()
{
node.complete_sync(&node_hash);
}
}
offer
}
}
@@ -1589,11 +1581,11 @@ impl PropagationSyncTask {
let completed_ids = std::mem::take(&mut self.active_transfer_ids);
self.record_handled_updates(&completed_ids);
if let Some(node_hash) = self.node_dest_hash {
if let Ok(mut node) = self.propagation_node.lock() {
if let Some(node_hash) = self.node_dest_hash
&& let Ok(mut node) = self.propagation_node.lock()
{
node.complete_sync(&node_hash);
}
}
self.state = SyncTaskState::Complete;
}
@@ -1741,11 +1733,11 @@ impl PropagationSyncTask {
peer.link_closed();
}
if let Some(link_id) = self.link_id.take() {
if !graceful_release {
if let Some(link_id) = self.link_id.take()
&& !graceful_release
{
self.queue_endpoint_cleanup(link_id);
}
}
self.attached_interface = None;
self.pending_endpoint_bind = None;
self.link = None;
+6 -9
View File
@@ -561,8 +561,9 @@ impl LxmRouter {
}
}
if message.method == DeliveryMethod::Opportunistic {
if let Ok(packed) = message.pack_payload() {
if message.method == DeliveryMethod::Opportunistic
&& let Ok(packed) = message.pack_payload()
{
let content_size = packed
.len()
.saturating_sub(TIMESTAMP_SIZE + STRUCT_OVERHEAD);
@@ -572,7 +573,6 @@ impl LxmRouter {
message.method = DeliveryMethod::Direct;
}
}
}
message.state = MessageState::Outbound;
self.pending_outbound.push(message);
@@ -591,14 +591,13 @@ impl LxmRouter {
message: &mut LxMessage,
) -> Result<(), TicketPreparationError> {
let now = now_f64();
if message.outbound_ticket.is_none() {
if let Some(ticket) = self
if message.outbound_ticket.is_none()
&& let Some(ticket) = self
.ticket_store
.find_outbound(&message.destination_hash, now)
{
message.outbound_ticket = Some(ticket.token);
}
}
if message.include_ticket && !message.fields.contains_key(&FIELD_TICKET) {
if message.signature.is_some() {
@@ -915,11 +914,9 @@ impl LxmRouter {
.active_deferred_stamp
.as_ref()
.is_some_and(|job| job.message_hash == *message_hash);
if active_matches {
if let Some(job) = self.active_deferred_stamp.take() {
if active_matches && let Some(job) = self.active_deferred_stamp.take() {
job.handle.cancel();
}
}
return true;
}
+121 -146
View File
@@ -323,16 +323,15 @@ fn apply_propagation_store_commit(
for (transient_id, _) in result.committed {
peer.add_handled_message(&transient_id);
}
if let Some(node) = node {
if let Ok(node) = node.lock() {
if let Err(error) = node.save_peer(peer) {
if let Some(node) = node
&& let Ok(node) = node.lock()
&& let Err(error) = node.save_peer(peer)
{
tracing::warn!(
peer = %hex::encode(peer_hash),
"failed to persist committed peer accounting: {error}"
);
}
}
}
} else {
router.unpeered_propagation_incoming = router
.unpeered_propagation_incoming
@@ -1396,19 +1395,20 @@ impl LxmdRunner {
if let Ok(entries) = std::fs::read_dir(&received_dir) {
for entry in entries.flatten() {
let path = entry.path();
if let Some(name) = path.file_stem().and_then(|n| n.to_str()) {
if let Ok(rr) = ReceivedRatchet::load(&path) {
if let Some(name) = path.file_stem().and_then(|n| n.to_str())
&& let Ok(rr) = ReceivedRatchet::load(&path)
{
received_ratchets.insert(name.to_string(), rr);
}
}
}
}
// known_identities format: concat of [dest_hash:16][pubkey:64]
let ki_path = paths.known_identities_path.clone();
let mut known_identities: HashMap<String, [u8; 64]> = HashMap::new();
if ki_path.exists() {
if let Ok(data) = std::fs::read(&ki_path) {
if ki_path.exists()
&& let Ok(data) = std::fs::read(&ki_path)
{
let mut pos = 0;
while pos + 80 <= data.len() {
let mut dh = [0u8; 16];
@@ -1419,7 +1419,6 @@ impl LxmdRunner {
pos += 80;
}
}
}
tracing::info!(
ratchet_keys = delivery_ratchets.ring().len(),
@@ -2080,12 +2079,12 @@ impl LxmdRunner {
match parse_destination_hash(configured) {
Ok(hash) => {
self.router.prioritise(hash, 1);
if let Some(ref node) = self.propagation_node {
if let Ok(mut node) = node.lock() {
if let Some(ref node) = self.propagation_node
&& let Ok(mut node) = node.lock()
{
node.prioritise_destination(hash);
}
}
}
Err(e) => {
tracing::warn!(hash = %configured, "ignoring invalid prioritised destination hash: {e}")
}
@@ -2222,16 +2221,15 @@ impl LxmdRunner {
// Upstream control unpeer breaks the live peering without
// mutating the operator's configured static-peer set.
self.router.remove_peer(&peer_hash);
if let Some(ref node) = self.propagation_node {
if let Ok(mut node) = node.lock() {
if let Err(error) = node.delete_peer(&peer_hash) {
if let Some(ref node) = self.propagation_node
&& let Ok(mut node) = node.lock()
&& let Err(error) = node.delete_peer(&peer_hash)
{
tracing::warn!(
peer = %hex::encode(peer_hash),
"failed to remove persisted propagation peer: {error}"
);
}
}
}
if let Err(e) = self.router.save_state(&self.data_dir) {
tracing::warn!("Failed to save router state after control unpeer: {e}");
}
@@ -2253,28 +2251,26 @@ impl LxmdRunner {
// announce timebase (or a lower current target) does not make
// a completed key stale if its measured value is still high
// enough for the current policy.
if let Some((key, value)) = result.peering_key {
if value >= peer.peering_cost as u32 {
if let Some((key, value)) = result.peering_key
&& value >= peer.peering_cost as u32
{
peer.peering_key = Some((key, value));
applied = true;
}
}
}
if applied {
if let (Some(node), Some(peer)) = (
self.propagation_node.as_ref(),
self.router.peers.get(&result.peer_hash),
) {
if let Ok(node) = node.lock() {
if let Err(error) = node.save_peer(peer) {
) && let Ok(node) = node.lock()
&& let Err(error) = node.save_peer(peer)
{
tracing::warn!(
peer = %hex::encode(result.peer_hash),
"failed to persist generated peering key: {error}"
);
}
}
}
} else if current_cost {
// A bounded key search can fail for an excessive advertised
// cost. Put this policy generation into the normal peer
@@ -2354,15 +2350,15 @@ impl LxmdRunner {
.then(|| OutboundOfferPolicy::from(peer))
});
if let Some(policy) = policy {
if let Some(sync) = self.propagation_sync.as_mut() {
if sync.request_sync_now_with_policy(policy) {
if let Some(sync) = self.propagation_sync.as_mut()
&& sync.request_sync_now_with_policy(policy)
{
if let Some(peer) = self.router.peers.get_mut(&peer_hash) {
peer.begin_sync();
}
self.pending_peer_syncs.remove(&peer_hash);
self.peer_sync_cursor = Some(peer_hash);
}
}
return;
}
@@ -2471,17 +2467,16 @@ impl LxmdRunner {
link_id,
packet_hash,
} => {
if let Some(ld) = &mut self.link_delivery {
if !ld.abandon_backchannel_packet(link_id, packet_hash) {
self.pending_backchannel_abandon =
Some(BackchannelSendReceipt::Packet {
if let Some(ld) = &mut self.link_delivery
&& !ld.abandon_backchannel_packet(link_id, packet_hash)
{
self.pending_backchannel_abandon = Some(BackchannelSendReceipt::Packet {
link_id,
packet_hash,
});
break;
}
}
}
BackchannelSendReceipt::Resource {
link_id,
resource_hash,
@@ -2727,25 +2722,26 @@ impl LxmdRunner {
sync.drain_events(&self.known_identities);
sync.tick();
let updates = sync.take_handled_updates();
if !updates.is_empty() {
if let Some(peer_hash) = sync.node_dest_hash() {
if !updates.is_empty()
&& let Some(peer_hash) = sync.node_dest_hash()
{
peer_handled_updates = Some((peer_hash, updates));
}
}
peer_terminal_result = sync.take_terminal_peer_result();
}
let mut peers_to_persist = HashSet::new();
if let Some((peer_hash, updates)) = peer_handled_updates {
if let Some(peer) = self.router.peers.get_mut(&peer_hash) {
if let Some((peer_hash, updates)) = peer_handled_updates
&& let Some(peer) = self.router.peers.get_mut(&peer_hash)
{
for transient_id in updates {
peer.add_handled_message(&transient_id);
}
peers_to_persist.insert(peer_hash);
}
}
if let Some(result) = peer_terminal_result {
if let Some(peer) = self.router.peers.get_mut(&result.peer_hash) {
if let Some(result) = peer_terminal_result
&& let Some(peer) = self.router.peers.get_mut(&result.peer_hash)
{
if let Some(rate) = result.link_establishment_rate {
peer.link_establishment_rate = rate;
peer.heard();
@@ -2759,26 +2755,25 @@ impl LxmdRunner {
peer.sync_transfer_rate = rate;
}
peer.sync_complete();
if result.generation_exhausted {
if let Some(generation) = result.offer_generation {
if result.generation_exhausted
&& let Some(generation) = result.offer_generation
{
peer.mark_offer_generation_processed(generation);
}
}
}
lxmf_core::propagation_sync::PeerSyncTerminalState::Failed => {
peer.sync_failed();
}
}
peers_to_persist.insert(result.peer_hash);
}
}
for peer_hash in peers_to_persist {
if let (Some(node), Some(peer)) = (
self.propagation_node.as_ref(),
self.router.peers.get(&peer_hash),
) {
if let Ok(node) = node.lock() {
if let Err(error) = node.save_peer(peer) {
) && let Ok(node) = node.lock()
&& let Err(error) = node.save_peer(peer)
{
tracing::warn!(
peer = %hex::encode(peer_hash),
"failed to persist peer sync state: {error}"
@@ -2786,8 +2781,6 @@ impl LxmdRunner {
}
}
}
}
}
fn queue_runtime_transport(
&mut self,
@@ -3014,20 +3007,20 @@ impl LxmdRunner {
client.start_download();
self.last_propagation_check = now;
tracing::debug!("auto-triggered propagation download");
} else if let Some(node) = self.router.outbound_propagation_node {
if queue_unknown_propagation_node_path_request(
} else if let Some(node) = self.router.outbound_propagation_node
&& queue_unknown_propagation_node_path_request(
&self.transport_tx,
node,
&mut self.last_propagation_check,
now,
) {
)
{
tracing::debug!(
node = %hex::encode(node),
"propagation node identity unknown; requesting path before download"
);
}
}
}
let status = client.transfer_status();
acknowledge_propagation = matches!(
status.state,
@@ -3043,15 +3036,14 @@ impl LxmdRunner {
for msg_data in downloaded_messages {
self.handle_propagation_downloaded_data(&msg_data);
}
if acknowledge_propagation {
if let Some(client) = self.propagation_client.as_mut() {
if acknowledge_propagation && let Some(client) = self.propagation_client.as_mut() {
client.acknowledge_transfer();
}
}
if let Some(interval) = self.config.announce_interval {
if now - self.last_peer_announce > interval as f64 {
if let Ok(raw) = self.create_announce_packet() {
if let Some(interval) = self.config.announce_interval
&& now - self.last_peer_announce > interval as f64
&& let Ok(raw) = self.create_announce_packet()
{
let dest = self.lxmf_dest_hash;
if self.queue_runtime_transport(
TransportMessage::Outbound(rns_transport::messages::OutboundRequest {
@@ -3064,13 +3056,12 @@ impl LxmdRunner {
tracing::debug!("periodic peer announce staged");
}
}
}
}
if self.config.propagation_enabled {
if let Some(interval) = self.config.node_announce_interval {
if now - self.last_node_announce > interval as f64 {
if let Ok(raw) = self.create_propagation_announce_packet() {
if self.config.propagation_enabled
&& let Some(interval) = self.config.node_announce_interval
&& now - self.last_node_announce > interval as f64
&& let Ok(raw) = self.create_propagation_announce_packet()
{
let dest = self.propagation_dest_hash;
let node_staged = self.queue_runtime_transport(
TransportMessage::Outbound(rns_transport::messages::OutboundRequest {
@@ -3080,30 +3071,23 @@ impl LxmdRunner {
"periodic propagation announce",
);
let mut control_staged = true;
if self.should_announce_control() {
if let Ok(raw) = create_control_announce_packet(
&self.identity,
self.control_dest_hash,
) {
if self.should_announce_control()
&& let Ok(raw) =
create_control_announce_packet(&self.identity, self.control_dest_hash)
{
control_staged = self.queue_runtime_transport(
TransportMessage::Outbound(
rns_transport::messages::OutboundRequest {
TransportMessage::Outbound(rns_transport::messages::OutboundRequest {
raw: Bytes::from(raw),
destination_hash: self.control_dest_hash,
},
),
}),
"periodic control announce",
);
}
}
if node_staged && control_staged {
self.last_node_announce = now;
tracing::debug!("periodic propagation node announce staged");
}
}
}
}
}
if now - self.last_cull > 300.0 {
self.router.cull_stamp_costs();
@@ -3111,11 +3095,11 @@ impl LxmdRunner {
// jobloop cadences. The propagation node's own store (separate
// from the router's) ages out expired messages and enforces the
// weight cap here — previously this never ran.
if let Some(ref pn) = self.propagation_node {
if let Ok(mut node) = pn.lock() {
if let Some(ref pn) = self.propagation_node
&& let Ok(mut node) = pn.lock()
{
node.tick();
}
}
self.last_cull = now;
}
@@ -3169,8 +3153,8 @@ impl LxmdRunner {
.insert(event.destination_hash, event.hops.max(1));
if event.name_hash == delivery_name_hash {
if let Some(ref data) = event.app_data {
if let Some((display_name, stamp_cost)) =
if let Some(ref data) = event.app_data
&& let Some((display_name, stamp_cost)) =
lxmf_core::handlers::parse_announce_app_data(data)
{
if let Some(name) = display_name {
@@ -3185,7 +3169,6 @@ impl LxmdRunner {
);
}
}
}
let triggered = self
.router
.trigger_outbound_for_delivery_announce(event.destination_hash);
@@ -3257,16 +3240,15 @@ impl LxmdRunner {
if let Some(sync) = self.propagation_sync.as_mut() {
sync.cancel_peer_sync(&event.destination_hash);
}
if let Some(node) = self.propagation_node.as_ref() {
if let Ok(mut node) = node.lock() {
if let Err(error) = node.delete_peer(&event.destination_hash) {
if let Some(node) = self.propagation_node.as_ref()
&& let Ok(mut node) = node.lock()
&& let Err(error) = node.delete_peer(&event.destination_hash)
{
tracing::warn!(
peer = %dest_hex,
"failed to remove retired propagation peer: {error}"
);
}
}
}
} else if peer_changed {
let offer_constraints_changed =
previous_offer_constraints.is_some_and(|previous| {
@@ -3290,17 +3272,15 @@ impl LxmdRunner {
if let (Some(node), Some(peer)) = (
self.propagation_node.as_ref(),
self.router.peers.get(&event.destination_hash),
) {
if let Ok(node) = node.lock() {
if let Err(error) = node.save_peer(peer) {
) && let Ok(node) = node.lock()
&& let Err(error) = node.save_peer(peer)
{
tracing::warn!(
peer = %dest_hex,
"failed to persist propagation peer policy: {error}"
);
}
}
}
}
tracing::debug!(
dest = %dest_hex,
stamp_cost = pn.stamp_cost,
@@ -3317,17 +3297,17 @@ impl LxmdRunner {
);
}
}
if let Some(pub_key) = event.public_key {
if self.known_identities.get(&dest_hex) != Some(&pub_key) {
if let Some(pub_key) = event.public_key
&& self.known_identities.get(&dest_hex) != Some(&pub_key)
{
self.known_identities.insert(dest_hex.clone(), pub_key);
tracing::debug!(dest = %dest_hex, "learned identity key from announce");
}
}
// Python Identity._remember_ratchet: persist only the single
// changed ratchet, off the daemon loop. Identity keys and the
// ring stay on the periodic/shutdown saves.
if let Some(ratchet_key) = event.ratchet {
if self
if let Some(ratchet_key) = event.ratchet
&& self
.received_ratchets
.get(&dest_hex)
.is_none_or(|rr| rr.ratchet_pub != ratchet_key)
@@ -3347,7 +3327,6 @@ impl LxmdRunner {
});
}
}
}
seen
}
@@ -3366,12 +3345,11 @@ impl LxmdRunner {
direction: LinkResourceDirection::Inbound,
..
}
) {
if let Some(event) = delivery_resource_event_from_runtime(event) {
) && let Some(event) = delivery_resource_event_from_runtime(event)
{
self.router.handle_inbound_resource_event(event);
}
}
}
while let Ok((plaintext, link_id)) = self.link_packet_rx.try_recv() {
tracing::info!(
@@ -3661,8 +3639,9 @@ impl LxmdRunner {
.map(PropagationStoreWriteOrigin::Peer)
.unwrap_or(PropagationStoreWriteOrigin::Client);
let mut write_plans = Vec::new();
if let Some(ref node) = self.propagation_node {
if let Ok(mut node) = node.lock() {
if let Some(ref node) = self.propagation_node
&& let Ok(mut node) = node.lock()
{
for entry in &result.entries {
let stamp_value = u8::try_from(entry.stamp_value).unwrap_or(u8::MAX);
if let Some(plan) = node.plan_accept_stamped_propagated_blob(
@@ -3674,19 +3653,18 @@ impl LxmdRunner {
}
}
}
}
let reserved = write_plans.len();
if let Some(node) = self.propagation_node.clone() {
if let Some(task) = spawn_propagation_store_writes(
if let Some(node) = self.propagation_node.clone()
&& let Some(task) = spawn_propagation_store_writes(
node,
write_plans,
write_origin,
self.prop_store_commit_tx.clone(),
"propagation Resource ingress",
) {
)
{
self.prop_store_write_tasks.push(task);
}
}
tracing::info!(
link_id = %hex::encode(claim.link_id()),
@@ -3696,8 +3674,9 @@ impl LxmdRunner {
"processed inbound propagation Resource"
);
if claim.should_close_link() {
if let Some(command_tx) = self.prop_link_command_tx.clone() {
if claim.should_close_link()
&& let Some(command_tx) = self.prop_link_command_tx.clone()
{
let link_id = claim.link_id();
tokio::spawn(async move {
if command_tx
@@ -3717,7 +3696,6 @@ impl LxmdRunner {
});
}
}
}
fn handle_propagation_transfer_data(&mut self, link_id: [u8; 16], data: &[u8]) {
if self
@@ -3780,8 +3758,9 @@ impl LxmdRunner {
result: PnPacketValidationWorkerResult,
) {
let mut write_plans = Vec::new();
if let Some(ref node) = self.propagation_node {
if let Ok(mut node) = node.lock() {
if let Some(ref node) = self.propagation_node
&& let Ok(mut node) = node.lock()
{
for entry in &result.entries {
if let Some(plan) = node.plan_accept_stamped_propagated_blob(
&entry.lxmf_data,
@@ -3792,19 +3771,18 @@ impl LxmdRunner {
}
}
}
}
let reserved = write_plans.len();
if let Some(node) = self.propagation_node.clone() {
if let Some(task) = spawn_propagation_store_writes(
if let Some(node) = self.propagation_node.clone()
&& let Some(task) = spawn_propagation_store_writes(
node,
write_plans,
PropagationStoreWriteOrigin::Client,
self.prop_store_commit_tx.clone(),
"client packet ingress",
) {
)
{
self.prop_store_write_tasks.push(task);
}
}
tracing::info!(
link_id = %hex::encode(result.link_id),
@@ -3813,8 +3791,9 @@ impl LxmdRunner {
"processed inbound propagation packet"
);
if result.rejected > 0 {
if let Some(command_tx) = self.prop_link_command_tx.clone() {
if result.rejected > 0
&& let Some(command_tx) = self.prop_link_command_tx.clone()
{
tokio::spawn(async move {
let _ = command_tx
.send(rns_runtime::link_manager::LinkManagerCommand::CloseLink {
@@ -3826,7 +3805,6 @@ impl LxmdRunner {
});
}
}
}
fn handle_propagation_downloaded_data(&mut self, data: &[u8]) {
if data.len() < 16 {
@@ -4165,8 +4143,8 @@ impl LxmdRunner {
}
let hops = route_hops_for(&self.route_hops, prop_hash);
self.ensure_link_delivery();
if let Some(ref mut ld) = self.link_delivery {
if let Err(err) = ld
if let Some(ref mut ld) = self.link_delivery
&& let Err(err) = ld
.start_packed_delivery(message, prop_hash, hops, packed, false)
{
let reason = err.error.to_string();
@@ -4185,7 +4163,6 @@ impl LxmdRunner {
);
}
}
}
None => {
tracing::warn!(
dest = %hex::encode(message.destination_hash),
@@ -4218,9 +4195,10 @@ impl LxmdRunner {
}
};
if message.stamp.is_none() {
if let Some(cost) = self.router.get_stamp_cost(&message.destination_hash) {
if cost > 0 {
if message.stamp.is_none()
&& let Some(cost) = self.router.get_stamp_cost(&message.destination_hash)
&& cost > 0
{
tracing::info!(
dest = %hex::encode(message.destination_hash),
cost = cost,
@@ -4229,8 +4207,6 @@ impl LxmdRunner {
message.stamp_cost = Some(cost);
message.get_stamp();
}
}
}
let dest_hex = hex::encode(dest_hash);
if !is_opportunistic {
@@ -4483,8 +4459,9 @@ impl LxmdRunner {
}
let hops = route_hops_for(&self.route_hops, dest_hash);
self.ensure_link_delivery();
if let Some(ref mut ld) = self.link_delivery {
if let Err(err) = ld.start_delivery(message, dest_hash, hops) {
if let Some(ref mut ld) = self.link_delivery
&& let Err(err) = ld.start_delivery(message, dest_hash, hops)
{
let reason = err.error.to_string();
tracing::warn!(
error = %reason,
@@ -4500,7 +4477,6 @@ impl LxmdRunner {
false,
);
}
}
continue;
}
@@ -4667,13 +4643,13 @@ impl LxmdRunner {
let ki_path = ratchet_dir.join("known_identities");
let mut data = Vec::with_capacity(self.known_identities.len() * 80);
for (hash_hex, pk) in &self.known_identities {
if let Ok(hash_bytes) = hex::decode(hash_hex) {
if hash_bytes.len() == 16 {
if let Ok(hash_bytes) = hex::decode(hash_hex)
&& hash_bytes.len() == 16
{
data.extend_from_slice(&hash_bytes);
data.extend_from_slice(pk);
}
}
}
if let Err(e) = rns_identity::persistence::atomic_write(&ki_path, &data) {
tracing::warn!("Failed to save known identities: {e}");
}
@@ -4947,13 +4923,13 @@ pub(crate) async fn main() {
);
for destination in ignored {
runner.router.ignore_destination(destination);
if let Some(ref node) = runner.propagation_node {
if let Ok(mut node) = node.lock() {
if let Some(ref node) = runner.propagation_node
&& let Ok(mut node) = node.lock()
{
node.ignore_destination(destination);
}
}
}
}
let allowed = load_hash_list(&config_dir.join("allowed"));
if !allowed.is_empty() {
tracing::info!(
@@ -5281,11 +5257,10 @@ pub(crate) async fn main() {
direction: LinkResourceDirection::Inbound,
..
}
) {
if let Some(event) = delivery_resource_event_from_runtime(event) {
)
&& let Some(event) = delivery_resource_event_from_runtime(event) {
runner.router.handle_inbound_resource_event(event);
}
}
runner.drain_link_packets();
}
Some((data, link_id)) = runner.prop_link_packet_rx.recv() => {
+7 -8
View File
@@ -324,18 +324,17 @@ impl DaemonConfig {
dc.outbound_propagation_node = Some(trimmed.to_string());
}
}
if get_int(Some(sec), "propagation_stamp_cost_target").is_none() {
if let Some(cost) = sec.get_uint("propagation_stamp_cost") {
if get_int(Some(sec), "propagation_stamp_cost_target").is_none()
&& let Some(cost) = sec.get_uint("propagation_stamp_cost")
{
dc.propagation_stamp_cost = cost as u8;
}
}
if get_float(Some(sec), "propagation_message_max_accepted_size").is_none()
&& get_float(Some(sec), "propagation_transfer_max_accepted_size").is_none()
&& let Some(limit) = sec.get_uint("propagation_limit")
{
if let Some(limit) = sec.get_uint("propagation_limit") {
dc.propagation_limit_kb = limit as usize;
}
}
dc.enforce_stamps = sec.get_bool_or("enforce_stamps", false);
}
@@ -343,8 +342,9 @@ impl DaemonConfig {
if !dc.auth_required {
dc.auth_required = sec.get_bool_or("auth_required", false);
}
if dc.control_allowed.is_empty() {
if let Some(allowed) = sec.get("allowed") {
if dc.control_allowed.is_empty()
&& let Some(allowed) = sec.get("allowed")
{
dc.control_allowed = allowed
.split(',')
.map(|s| s.trim().to_string())
@@ -352,7 +352,6 @@ impl DaemonConfig {
.collect();
}
}
}
dc
}
+3 -3
View File
@@ -111,11 +111,11 @@ pub fn decode_control_response(response: &[u8]) -> ControlResponse {
return ControlResponse::Success;
};
if let Some(code) = value.as_u64() {
if let Some(error) = peer_error_from_code(code as u8) {
if let Some(code) = value.as_u64()
&& let Some(error) = peer_error_from_code(code as u8)
{
return ControlResponse::Error(error);
}
}
if value.is_nil() {
ControlResponse::Empty
+3 -3
View File
@@ -11,7 +11,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
EXPECTED_RUST_VERSION = "1.87"
EXPECTED_RUST_VERSION = "1.89"
SHA_PATTERN = re.compile(r"^[0-9a-f]{40}$")
@@ -94,8 +94,8 @@ def check_workflow_actions() -> None:
def check_release_workflow(reticulum_version: str) -> str:
workflow = (ROOT / ".github/workflows/release.yml").read_text()
if not re.search(r"^\s*toolchain:\s*1\.87\.0\s*$", workflow, re.MULTILINE):
fail("release workflow does not select Rust 1.87.0")
if not re.search(r"^\s*toolchain:\s*1\.89\.0\s*$", workflow, re.MULTILINE):
fail("release workflow does not select Rust 1.89.0")
if "ref: ${{ env.RELEASE_TAG }}" not in workflow:
fail("release workflow does not check out RELEASE_TAG")