Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
wfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyakovenko committed Apr 12, 2018
1 parent c350adb commit ce98679
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
11 changes: 7 additions & 4 deletions src/accountant_skel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,11 @@ pub fn to_packets(r: &packet::PacketRecycler, reqs: Vec<Request>) -> Vec<SharedP
let mut out = vec![];
for rrs in reqs.chunks(packet::NUM_PACKETS) {
let p = r.allocate();
p.write().unwrap().packets.resize(rrs.len(), Default::default());
for (i,o) in rrs.iter().zip(p.write().unwrap().packets.iter_mut()) {
p.write()
.unwrap()
.packets
.resize(rrs.len(), Default::default());
for (i, o) in rrs.iter().zip(p.write().unwrap().packets.iter_mut()) {
let v = serialize(&i).expect("serialize request");
let len = v.len();
o.data[..len].copy_from_slice(&v);
Expand All @@ -294,15 +297,15 @@ mod tests {
use accountant_skel::{to_packets, Request};
use bincode::serialize;
use ecdsa;
use packet::{PacketRecycler, NUM_PACKETS};
use transaction::{memfind, test_tx};
use packet::{NUM_PACKETS, PacketRecycler};
#[test]
fn test_layout() {
let tr = test_tx();
let tx = serialize(&tr).unwrap();
let packet = serialize(&Request::Transaction(tr)).unwrap();
assert_matches!(memfind(&packet, &tx), Some(ecdsa::TX_OFFSET));
assert_matches!(memfind(&packet, &[0,1,2,3,4,5,6,7,8,9]), None);
assert_matches!(memfind(&packet, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), None);
}
#[test]
fn test_to_packets() {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/client-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ extern crate rayon;
extern crate serde_json;
extern crate solana;

use getopts::Options;
use rayon::prelude::*;
use solana::accountant_stub::AccountantStub;
use solana::mint::Mint;
use solana::signature::{KeyPair, KeyPairUtil};
use solana::transaction::Transaction;
use std::env;
use std::io::stdin;
use std::net::UdpSocket;
use std::thread::sleep;
use std::time::{Duration, Instant};
use std::env;
use getopts::Options;

fn main() {
let mut threads = 4usize;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/testnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ extern crate getopts;
extern crate serde_json;
extern crate solana;

use getopts::Options;
use solana::accountant::Accountant;
use solana::accountant_skel::AccountantSkel;
use solana::entry::Entry;
use solana::event::Event;
use solana::historian::Historian;
use std::env;
use std::io::{self, stdout, BufRead};
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex};
use std::env;
use getopts::Options;

fn main() {
env_logger::init().unwrap();
Expand Down
8 changes: 4 additions & 4 deletions src/ecdsa.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use packet::{Packet, SharedPackets};
use transaction::{PUB_KEY_OFFSET, SIGNED_DATA_OFFSET, SIG_OFFSET};
use std::mem::size_of;
use transaction::{PUB_KEY_OFFSET, SIGNED_DATA_OFFSET, SIG_OFFSET};

pub const TX_OFFSET: usize = 4;

Expand Down Expand Up @@ -29,8 +29,8 @@ extern "C" {
#[cfg(not(feature = "cuda"))]
fn verify_packet(packet: &Packet) -> u8 {
use ring::signature;
use untrusted;
use signature::{PublicKey, Signature};
use untrusted;

let msg_start = TX_OFFSET + SIGNED_DATA_OFFSET;
let sig_start = TX_OFFSET + SIG_OFFSET;
Expand Down Expand Up @@ -130,12 +130,12 @@ pub fn ed25519_verify(batches: &Vec<SharedPackets>) -> Vec<Vec<u8>> {

#[cfg(test)]
mod tests {
use transaction::test_tx;
use accountant_skel::Request;
use bincode::serialize;
use ecdsa;
use std::sync::RwLock;
use packet::{Packet, Packets, SharedPackets};
use std::sync::RwLock;
use transaction::test_tx;
use transaction::Transaction;

fn make_packet_from_transaction(tr: Transaction) -> Packet {
Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The `hash` module provides functions for creating SHA-256 hashes.
use generic_array::GenericArray;
use generic_array::typenum::U32;
use generic_array::GenericArray;
use sha2::{Digest, Sha256};

pub type Hash = GenericArray<u8, U32>;
Expand Down
2 changes: 1 addition & 1 deletion src/mint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The `mint` module is a library for generating the chain's genesis block.
use entry::Entry;
use entry::create_entry;
use entry::Entry;
use event::Event;
use hash::{hash, Hash};
use ring::rand::SystemRandom;
Expand Down
2 changes: 1 addition & 1 deletion src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ mod tests {
use std::io;
use std::io::Write;
use std::net::SocketAddr;
use std::sync::mpsc::channel;
use std::sync::mpsc::RecvError;
use std::sync::mpsc::RecvTimeoutError;
use std::sync::mpsc::channel;
use std::thread;

fn addr_parse_error() -> Result<SocketAddr> {
Expand Down
2 changes: 1 addition & 1 deletion src/signature.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The `signature` module provides functionality for public, and private keys.
use generic_array::GenericArray;
use generic_array::typenum::{U32, U64};
use generic_array::GenericArray;
use ring::signature::Ed25519KeyPair;
use ring::{rand, signature};
use untrusted;
Expand Down
4 changes: 2 additions & 2 deletions src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use packet::{Blob, BlobRecycler, PacketRecycler, SharedBlob, SharedPackets, NUM_
use result::Result;
use std::collections::VecDeque;
use std::net::UdpSocket;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc;
use std::sync::Arc;
use std::thread::{spawn, JoinHandle};
use std::time::Duration;

Expand Down Expand Up @@ -246,9 +246,9 @@ mod test {
use std::io;
use std::io::Write;
use std::net::UdpSocket;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::time::Duration;
use streamer::{receiver, responder, window, BlobReceiver, PacketReceiver};

Expand Down

0 comments on commit ce98679

Please sign in to comment.