Skip to content

Commit

Permalink
try sending less then 256 to process
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyakovenko committed Apr 4, 2018
1 parent 228c38c commit e514b3c
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/accountant_skel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<W: Write + Send + 'static> AccountantSkel<W> {
.take(256) // TODO: Take while the serialized entries fit into a 64k UDP packet.
.cloned()
.collect();
assert!(serialize(&entries).unwrap().len() < 64 * 1024);
//assert!(serialize(&entries).unwrap().len() < 64 * 1024);
Some(Response::Entries { entries })
}
Request::GetId { is_last } => Some(Response::Id {
Expand All @@ -105,23 +105,34 @@ impl<W: Write + Send + 'static> AccountantSkel<W> {
) -> Result<()> {
let timer = Duration::new(1, 0);
let msgs = recvr.recv_timeout(timer)?;

//println!("got msgs");
let mut v = Vec::new();
let mut len = msgs.read().unwrap().packets.len();
v.push(msgs);
while let Ok(more) = recvr.try_recv() {
//println!("got more msgs");
let l = more.read().unwrap().packets.len();
if len + l >= 256 {
let rvs = gpu::ecdsa_verify(&v);
sendr.send((v, rvs))?;
v.push(more);
}
//println!("verifying");
let rvs = gpu::ecdsa_verify(&v);
//println!("verified!");
let mut len = 0;
let mut sv = Vec::new();
let mut sr = Vec::new();
for (v, r) in v.iter().zip(rvs.iter()) {
if len + r.len() >= 256 {
println!("sending {}", len);
sendr.send((sv, sr))?;
sv = Vec::new();
sr = Vec::new();
len = 0;
}
len = l;
v = vec![more];
sv.push(v.clone());
sr.push(r.clone());
len += r.len();
assert!(len < 256);
}
if !v.is_empty() {
let rvs = gpu::ecdsa_verify(&v);
sendr.send((v, rvs))?;
if !sv.is_empty() {
sendr.send((sv, sr))?;
}
Ok(())
}
Expand Down

0 comments on commit e514b3c

Please sign in to comment.