relay work

This commit is contained in:
Christien Rioux
2023-07-19 20:55:37 -04:00
parent 2fc979235e
commit dfc2a09847
3 changed files with 49 additions and 12 deletions

View File

@@ -1046,11 +1046,17 @@ impl NetworkManager {
};
if let Some(relay_nr) = some_relay_nr {
// Ensure the protocol is forwarded exactly as is
// Ensure the protocol used to forward is of the same sequencing requirement
// Address type is allowed to change if connectivity is better
let relay_nr = relay_nr.filtered_clone(
NodeRefFilter::new().with_protocol_type(connection_descriptor.protocol_type()),
);
let relay_nr = if connection_descriptor.protocol_type().is_ordered() {
// XXX: this is a little redundant
let (_, nrf) = NodeRefFilter::new().with_sequencing(Sequencing::EnsureOrdered);
let mut relay_nr = relay_nr.filtered_clone(nrf);
relay_nr.set_sequencing(Sequencing::EnsureOrdered);
relay_nr
} else {
relay_nr
};
// Relay the packet to the desired destination
log_net!("relaying {} bytes to {}", data.len(), relay_nr);

View File

@@ -103,7 +103,7 @@ impl NetworkManager {
target_node_ref: NodeRef,
data: Vec<u8>,
) -> EyreResult<NetworkResult<SendDataKind>> {
// First try to send data to the last socket we've seen this peer on
// First try to send data to the last connection we've seen this peer on
let Some(connection_descriptor) = target_node_ref.last_connection() else {
return Ok(NetworkResult::no_connection_other(
format!("should have found an existing connection: {}", target_node_ref)
@@ -149,7 +149,7 @@ impl NetworkManager {
.is_some()
{
return Ok(NetworkResult::no_connection_other(
format!("failed to send to existing connection: {:?}", connection_descriptor)
format!("failed to send to unreachable node over existing connection: {:?}", connection_descriptor)
));
}