mirror of
https://github.com/zerotier/sequential-exchange.git
synced 2026-05-22 16:28:28 -07:00
fixed file download
This commit is contained in:
@@ -127,14 +127,14 @@ fn receive(peer: &Peer) {
|
||||
|
||||
fn main() {
|
||||
let mut filesystem2 = HashMap::new();
|
||||
let mut file = vec![0; 1 << 14];
|
||||
OsRng.fill_bytes(&mut file);
|
||||
filesystem2.insert("File1".to_string(), file);
|
||||
let mut file = vec![0; 1 << 16];
|
||||
OsRng.fill_bytes(&mut file);
|
||||
filesystem2.insert("File2".to_string(), file);
|
||||
filesystem2.insert("File1".to_string(), file);
|
||||
let mut file = vec![0; 1 << 18];
|
||||
OsRng.fill_bytes(&mut file);
|
||||
filesystem2.insert("File2".to_string(), file);
|
||||
let mut file = vec![0; 1 << 20];
|
||||
OsRng.fill_bytes(&mut file);
|
||||
filesystem2.insert("File3".to_string(), file);
|
||||
|
||||
let (send1, recv2) = channel();
|
||||
@@ -157,7 +157,7 @@ fn main() {
|
||||
peer1.seqex.send(&peer1.transport, Packet::RequestFile { filename: "File3".to_string() });
|
||||
peer1.seqex.send(&peer1.transport, Packet::RequestFile { filename: "File2".to_string() });
|
||||
|
||||
for _ in 0..3000 {
|
||||
for _ in 0..300 {
|
||||
receive(&peer1);
|
||||
receive(&peer2);
|
||||
thread::sleep(Duration::from_millis(1));
|
||||
|
||||
+1
-2
@@ -378,9 +378,8 @@ impl<SendData, RecvData, const CAP: usize> SeqEx<SendData, RecvData, CAP> {
|
||||
if entry.next_resend_time <= current_time {
|
||||
entry.next_resend_time = next_resend_time;
|
||||
app.send(entry.seq_no, entry.reply_no, &entry.data);
|
||||
} else {
|
||||
next_activity = next_activity.min(entry.next_resend_time);
|
||||
}
|
||||
next_activity = next_activity.min(entry.next_resend_time);
|
||||
}
|
||||
self.next_service_timestamp = next_activity;
|
||||
app.update_service_time(next_activity, current_time);
|
||||
|
||||
Reference in New Issue
Block a user