Minor changes/improvements.

This commit is contained in:
Sean Bowe 2016-09-25 17:28:25 -06:00
parent d93139396d
commit 8e5bccaf91
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
4 changed files with 15 additions and 16 deletions

View File

@ -1 +1,2 @@
pub const NETWORK_MAGIC: [u8; 8] = [0xee, 0xee, 0x1f, 0xcc, 0x1c, 0xee, 0xcc, 0x19];
pub const USE_DUMMY_CS: bool = true;

View File

@ -34,7 +34,6 @@ use bincode::SizeLimit::Infinite;
use bincode::rustc_serialize::{encode_into, decode_from};
use std::time::Duration;
const USE_DUMMY_CS: bool = true;
const LISTEN_ADDR: &'static str = "0.0.0.0:65530";
const PLAYERS: usize = 3;
pub const THREADS: usize = 8;

View File

@ -13,14 +13,11 @@ use self::consts::*;
mod dvd;
use self::dvd::*;
use bn::*;
use rand::{SeedableRng, Rng};
use std::io::{Read, Write, self};
use rand::Rng;
use std::io::Read;
use std::net::{TcpStream};
use std::thread;
use std::time::Duration;
use std::fs::{self, File};
use std::process::Command;
use bincode::SizeLimit::Infinite;
use bincode::rustc_serialize::{encode_into, decode_from};
use rustc_serialize::{Decodable, Encodable};
@ -49,11 +46,11 @@ impl ConnectionHandler {
}
fn handshake(&mut self) {
self.s.set_read_timeout(Some(Duration::from_secs(60)));
self.s.set_write_timeout(Some(Duration::from_secs(60)));
self.s.write(&NETWORK_MAGIC);
self.s.write(&self.peerid);
self.s.flush();
let _ = self.s.set_read_timeout(Some(Duration::from_secs(60)));
let _ = self.s.set_write_timeout(Some(Duration::from_secs(60)));
let _ = self.s.write(&NETWORK_MAGIC);
let _ = self.s.write(&self.peerid);
let _ = self.s.flush();
}
fn do_with_stream<T, E, F: Fn(&mut TcpStream) -> Result<T, E>>(&mut self, cb: F) -> T
@ -106,7 +103,7 @@ impl ConnectionHandler {
}
fn main() {
let mut comm;
let comm;
{
let mut entered_wrong = false;
loop {
@ -127,7 +124,7 @@ fn main() {
handler.write(&comm);
println!("Waiting to receive disc 'A' from coordinator server...");
let mut stage1_before = handler.read::<Stage1Contents>();
let stage1_before = handler.read::<Stage1Contents>();
let (pubkey, stage1_after): (PublicKey, Stage1Contents) = exchange_disc(
"A",
@ -151,7 +148,7 @@ fn main() {
drop(stage1_after);
println!("Waiting to receive disc 'C' from coordinator server...");
let mut stage2_before = handler.read::<Stage2Contents>();
let stage2_before = handler.read::<Stage2Contents>();
let stage2_after: Stage2Contents = exchange_disc(
"C",
@ -171,7 +168,7 @@ fn main() {
drop(stage2_after);
println!("Waiting to receive disc 'E' from coordinator server...");
let mut stage3_before = handler.read::<Stage3Contents>();
let stage3_before = handler.read::<Stage3Contents>();
let stage3_after: Stage3Contents = exchange_disc(
"E",

View File

@ -9,6 +9,9 @@ extern crate byteorder;
mod protocol;
mod consts;
use self::consts::*;
use std::fs::File;
use std::io::{Read, Write};
use protocol::*;
@ -17,7 +20,6 @@ use snark::*;
use bincode::SizeLimit::Infinite;
use bincode::rustc_serialize::{encode_into, decode_from};
const USE_DUMMY_CS: bool = true;
pub const THREADS: usize = 8;
fn main() {