Skip to content

Commit e6d92af

Browse files
committed
fix:bug fix
1 parent e5f32f1 commit e6d92af

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/packet_processor.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::{Arc, Barrier};
2+
13
use crate::{FragmentAssembler, RoutingHandler, network::NetworkError, types::Command};
24

35
use crossbeam_channel::{Receiver, select_biased};
@@ -25,6 +27,12 @@ pub trait Processor: Send {
2527
let idx = fragment.fragment_index;
2628
let mut shr = pkt.routing_header.clone();
2729
shr.reverse();
30+
shr.increase_hop_index();
31+
assert!(
32+
shr.hop_index == 1,
33+
"hop_index should be 1, got {}",
34+
shr.hop_index
35+
);
2836
self.routing_handler().send_ack(shr, pkt.session_id, idx)?;
2937
if let Some(msg) = self.assembler().add_fragment(
3038
fragment,
@@ -50,7 +58,8 @@ pub trait Processor: Send {
5058
Ok(())
5159
}
5260

53-
fn run(&mut self) {
61+
fn run(&mut self, barrier: Arc<Barrier>) {
62+
barrier.wait();
5463
let _ = self.routing_handler().start_flood(None);
5564
loop {
5665
select_biased! {

src/routing_handler.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct RoutingHandler {
8787
flood_counter: u64,
8888
controller_send: Sender<Box<dyn Event>>,
8989
buffer: Buffer,
90-
node_type: NodeType
90+
node_type: NodeType,
9191
}
9292

9393
impl RoutingHandler {
@@ -107,7 +107,7 @@ impl RoutingHandler {
107107
flood_seen: HashSet::new(),
108108
controller_send,
109109
buffer: Buffer::new(),
110-
node_type
110+
node_type,
111111
}
112112
}
113113

@@ -137,7 +137,11 @@ impl RoutingHandler {
137137
let packet = Packet::new_flood_request(
138138
SourceRoutingHeader::empty_route(),
139139
self.session_counter,
140-
FloodRequest::new(self.flood_counter, self.id),
140+
FloodRequest {
141+
flood_id: self.flood_counter,
142+
initiator_id: self.id,
143+
path_trace: vec![(self.id, self.node_type)],
144+
},
141145
);
142146
self.controller_send
143147
.send(Box::new(NodeEvent::FloodStarted(
@@ -415,14 +419,15 @@ impl RoutingHandler {
415419
Fragment::new(i as u64, total_n_fragments, Self::pad_chunk(chunk));
416420
let packet = Packet::new_fragment(shr.clone(), session_id, fragment);
417421
self.try_send(packet)?;
418-
419422
}
420-
421-
self.controller_send.send(Box::new(NodeEvent::MessageSent {
422-
notification_from: self.id,
423-
to: destination,
424-
})).map_err(|_e| NetworkError::ControllerDisconnected)?;
425-
423+
424+
self.controller_send
425+
.send(Box::new(NodeEvent::MessageSent {
426+
notification_from: self.id,
427+
to: destination,
428+
}))
429+
.map_err(|_e| NetworkError::ControllerDisconnected)?;
430+
426431
return Ok(());
427432
}
428433

src/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ pub enum ChatEvent {
316316
},
317317
ErrorClientNotFound {
318318
notification_from: NodeId,
319-
location: NodeId,
320319
not_found: NodeId,
321320
},
322321

0 commit comments

Comments
 (0)