mirror of https://github.com/zcash/mpc.git
Minor changes/improvements.
This commit is contained in:
parent
d93139396d
commit
8e5bccaf91
|
@ -1 +1,2 @@
|
||||||
pub const NETWORK_MAGIC: [u8; 8] = [0xee, 0xee, 0x1f, 0xcc, 0x1c, 0xee, 0xcc, 0x19];
|
pub const NETWORK_MAGIC: [u8; 8] = [0xee, 0xee, 0x1f, 0xcc, 0x1c, 0xee, 0xcc, 0x19];
|
||||||
|
pub const USE_DUMMY_CS: bool = true;
|
||||||
|
|
|
@ -34,7 +34,6 @@ use bincode::SizeLimit::Infinite;
|
||||||
use bincode::rustc_serialize::{encode_into, decode_from};
|
use bincode::rustc_serialize::{encode_into, decode_from};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
const USE_DUMMY_CS: bool = true;
|
|
||||||
const LISTEN_ADDR: &'static str = "0.0.0.0:65530";
|
const LISTEN_ADDR: &'static str = "0.0.0.0:65530";
|
||||||
const PLAYERS: usize = 3;
|
const PLAYERS: usize = 3;
|
||||||
pub const THREADS: usize = 8;
|
pub const THREADS: usize = 8;
|
||||||
|
|
|
@ -13,14 +13,11 @@ use self::consts::*;
|
||||||
mod dvd;
|
mod dvd;
|
||||||
use self::dvd::*;
|
use self::dvd::*;
|
||||||
|
|
||||||
use bn::*;
|
use rand::Rng;
|
||||||
use rand::{SeedableRng, Rng};
|
use std::io::Read;
|
||||||
use std::io::{Read, Write, self};
|
|
||||||
use std::net::{TcpStream};
|
use std::net::{TcpStream};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::fs::{self, File};
|
|
||||||
use std::process::Command;
|
|
||||||
use bincode::SizeLimit::Infinite;
|
use bincode::SizeLimit::Infinite;
|
||||||
use bincode::rustc_serialize::{encode_into, decode_from};
|
use bincode::rustc_serialize::{encode_into, decode_from};
|
||||||
use rustc_serialize::{Decodable, Encodable};
|
use rustc_serialize::{Decodable, Encodable};
|
||||||
|
@ -49,11 +46,11 @@ impl ConnectionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handshake(&mut self) {
|
fn handshake(&mut self) {
|
||||||
self.s.set_read_timeout(Some(Duration::from_secs(60)));
|
let _ = self.s.set_read_timeout(Some(Duration::from_secs(60)));
|
||||||
self.s.set_write_timeout(Some(Duration::from_secs(60)));
|
let _ = self.s.set_write_timeout(Some(Duration::from_secs(60)));
|
||||||
self.s.write(&NETWORK_MAGIC);
|
let _ = self.s.write(&NETWORK_MAGIC);
|
||||||
self.s.write(&self.peerid);
|
let _ = self.s.write(&self.peerid);
|
||||||
self.s.flush();
|
let _ = self.s.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_with_stream<T, E, F: Fn(&mut TcpStream) -> Result<T, E>>(&mut self, cb: F) -> T
|
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() {
|
fn main() {
|
||||||
let mut comm;
|
let comm;
|
||||||
{
|
{
|
||||||
let mut entered_wrong = false;
|
let mut entered_wrong = false;
|
||||||
loop {
|
loop {
|
||||||
|
@ -127,7 +124,7 @@ fn main() {
|
||||||
handler.write(&comm);
|
handler.write(&comm);
|
||||||
|
|
||||||
println!("Waiting to receive disc 'A' from coordinator server...");
|
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(
|
let (pubkey, stage1_after): (PublicKey, Stage1Contents) = exchange_disc(
|
||||||
"A",
|
"A",
|
||||||
|
@ -151,7 +148,7 @@ fn main() {
|
||||||
drop(stage1_after);
|
drop(stage1_after);
|
||||||
|
|
||||||
println!("Waiting to receive disc 'C' from coordinator server...");
|
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(
|
let stage2_after: Stage2Contents = exchange_disc(
|
||||||
"C",
|
"C",
|
||||||
|
@ -171,7 +168,7 @@ fn main() {
|
||||||
drop(stage2_after);
|
drop(stage2_after);
|
||||||
|
|
||||||
println!("Waiting to receive disc 'E' from coordinator server...");
|
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(
|
let stage3_after: Stage3Contents = exchange_disc(
|
||||||
"E",
|
"E",
|
||||||
|
|
|
@ -9,6 +9,9 @@ extern crate byteorder;
|
||||||
|
|
||||||
mod protocol;
|
mod protocol;
|
||||||
|
|
||||||
|
mod consts;
|
||||||
|
use self::consts::*;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use protocol::*;
|
use protocol::*;
|
||||||
|
@ -17,7 +20,6 @@ use snark::*;
|
||||||
use bincode::SizeLimit::Infinite;
|
use bincode::SizeLimit::Infinite;
|
||||||
use bincode::rustc_serialize::{encode_into, decode_from};
|
use bincode::rustc_serialize::{encode_into, decode_from};
|
||||||
|
|
||||||
const USE_DUMMY_CS: bool = true;
|
|
||||||
pub const THREADS: usize = 8;
|
pub const THREADS: usize = 8;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Reference in New Issue