Merge branch 'master' of github.com:ethcore/parity into discovery

This commit is contained in:
arkpar 2016-02-15 20:30:08 +01:00
commit a2c0508792
7 changed files with 1173 additions and 28 deletions

View File

@ -20,26 +20,6 @@ use util::*;
use header::BlockNumber;
use basic_types::LogBloom;
#[derive(Debug, PartialEq, Eq)]
/// Error indicating an expected value was not found.
pub struct Mismatch<T: fmt::Debug> {
/// Value expected.
pub expected: T,
/// Value found.
pub found: T,
}
#[derive(Debug, PartialEq, Eq)]
/// Error indicating value found is outside of a valid range.
pub struct OutOfBounds<T: fmt::Debug> {
/// Minimum allowed value.
pub min: Option<T>,
/// Maximum allowed value.
pub max: Option<T>,
/// Value found.
pub found: T,
}
/// Result of executing the transaction.
#[derive(PartialEq, Debug)]
pub enum ExecutionError {

View File

@ -20,6 +20,7 @@ use rustc_serialize::hex::FromHexError;
use network::NetworkError;
use rlp::DecoderError;
use io;
use std::fmt;
#[derive(Debug)]
/// Error in database subsystem.
@ -55,6 +56,27 @@ pub enum UtilError {
BadSize,
}
#[derive(Debug, PartialEq, Eq)]
/// Error indicating an expected value was not found.
pub struct Mismatch<T: fmt::Debug> {
/// Value expected.
pub expected: T,
/// Value found.
pub found: T,
}
#[derive(Debug, PartialEq, Eq)]
/// Error indicating value found is outside of a valid range.
pub struct OutOfBounds<T: fmt::Debug> {
/// Minimum allowed value.
pub min: Option<T>,
/// Maximum allowed value.
pub max: Option<T>,
/// Value found.
pub found: T,
}
impl From<FromHexError> for UtilError {
fn from(err: FromHexError) -> UtilError {
UtilError::FromHex(err)

1088
util/src/keys/directory.rs Normal file

File diff suppressed because it is too large Load Diff

19
util/src/keys/mod.rs Normal file
View File

@ -0,0 +1,19 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Key management module
pub mod directory;

View File

@ -142,6 +142,7 @@ pub mod io;
pub mod network;
pub mod log;
pub mod panics;
pub mod keys;
pub use common::*;
pub use misc::*;
@ -162,3 +163,6 @@ pub use semantic_version::*;
pub use network::*;
pub use io::*;
pub use log::*;
#[cfg(test)]
mod tests;

31
util/src/tests/helpers.rs Normal file
View File

@ -0,0 +1,31 @@
use common::*;
use std::path::PathBuf;
use std::fs::{remove_dir_all};
use std::env;
pub struct RandomTempPath {
path: PathBuf
}
impl RandomTempPath {
pub fn create_dir() -> RandomTempPath {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
fs::create_dir_all(dir.as_path()).unwrap();
RandomTempPath {
path: dir.clone()
}
}
pub fn as_path(&self) -> &PathBuf {
&self.path
}
}
impl Drop for RandomTempPath {
fn drop(&mut self) {
if let Err(e) = remove_dir_all(self.as_path()) {
panic!("failed to remove temp directory, probably something failed to destroyed ({})", e);
}
}
}

1
util/src/tests/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod helpers;