Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 8d171a3

Browse files
debrisniklasad1
authored andcommitted
remove util-error (#9054)
* remove util-error * fixed grumbles
1 parent e9bd41b commit 8d171a3

File tree

19 files changed

+71
-160
lines changed

19 files changed

+71
-160
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ethcore/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ rlp_compress = { path = "../util/rlp_compress" }
5252
rlp_derive = { path = "../util/rlp_derive" }
5353
kvdb = { path = "../util/kvdb" }
5454
kvdb-memorydb = { path = "../util/kvdb-memorydb" }
55-
util-error = { path = "../util/error" }
5655
snappy = { git = "https://github.com/paritytech/rust-snappy" }
5756
stop-guard = { path = "../util/stop-guard" }
5857
macros = { path = "../util/macros" }

ethcore/src/client/client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use itertools::Itertools;
2828
use journaldb;
2929
use trie::{TrieSpec, TrieFactory, Trie};
3030
use kvdb::{DBValue, KeyValueDB, DBTransaction};
31-
use util_error::UtilError;
3231

3332
// other
3433
use ethereum_types::{H256, Address, U256};
@@ -442,7 +441,7 @@ impl Importer {
442441
{
443442
trace_time!("import_old_block");
444443
// verify the block, passing the chain for updating the epoch verifier.
445-
let mut rng = OsRng::new().map_err(UtilError::from)?;
444+
let mut rng = OsRng::new()?;
446445
self.ancient_verifier.verify(&mut rng, &header, &chain)?;
447446

448447
// Commit results

ethcore/src/client/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl Default for ClientConfig {
152152
}
153153
#[cfg(test)]
154154
mod test {
155-
use super::{DatabaseCompactionProfile};
155+
use super::DatabaseCompactionProfile;
156156

157157
#[test]
158158
fn test_default_compaction_profile() {

ethcore/src/client/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use std::fmt::{Display, Formatter, Error as FmtError};
18-
use util_error::UtilError;
18+
use std::io;
1919
use ethtrie::TrieError;
2020

2121
/// Client configuration errors.
2222
#[derive(Debug)]
2323
pub enum Error {
2424
/// TrieDB-related error.
2525
Trie(TrieError),
26-
/// Util error
27-
Util(UtilError),
26+
/// Io error.
27+
Io(io::Error),
2828
}
2929

3030
impl From<TrieError> for Error {
@@ -33,9 +33,9 @@ impl From<TrieError> for Error {
3333
}
3434
}
3535

36-
impl From<UtilError> for Error {
37-
fn from(err: UtilError) -> Self {
38-
Error::Util(err)
36+
impl From<io::Error> for Error {
37+
fn from(err: io::Error) -> Self {
38+
Error::Io(err)
3939
}
4040
}
4141

@@ -49,7 +49,7 @@ impl Display for Error {
4949
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
5050
match *self {
5151
Error::Trie(ref err) => write!(f, "{}", err),
52-
Error::Util(ref err) => write!(f, "{}", err),
52+
Error::Io(ref err) => write!(f, "{}", err),
5353
}
5454
}
5555
}

ethcore/src/error.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use std::{fmt, error};
2020
use std::time::SystemTime;
2121
use ethereum_types::{H256, U256, Address, Bloom};
22-
use util_error::{self, UtilError};
2322
use snappy::InvalidInput;
2423
use unexpected::{Mismatch, OutOfBounds};
2524
use ethtrie::TrieError;
@@ -206,7 +205,6 @@ impl From<Error> for BlockImportError {
206205
match e {
207206
Error(ErrorKind::Block(block_error), _) => BlockImportErrorKind::Block(block_error).into(),
208207
Error(ErrorKind::Import(import_error), _) => BlockImportErrorKind::Import(import_error.into()).into(),
209-
Error(ErrorKind::Util(util_error::ErrorKind::Decoder(decoder_err)), _) => BlockImportErrorKind::Decoder(decoder_err).into(),
210208
_ => BlockImportErrorKind::Other(format!("other block import error: {:?}", e)).into(),
211209
}
212210
}
@@ -236,7 +234,6 @@ error_chain! {
236234
}
237235

238236
links {
239-
Util(UtilError, util_error::ErrorKind) #[doc = "Error concerning a utility"];
240237
Import(ImportError, ImportErrorKind) #[doc = "Error concerning block import." ];
241238
}
242239

@@ -326,7 +323,6 @@ impl From<BlockImportError> for Error {
326323
match err {
327324
BlockImportError(BlockImportErrorKind::Block(e), _) => ErrorKind::Block(e).into(),
328325
BlockImportError(BlockImportErrorKind::Import(e), _) => ErrorKind::Import(e).into(),
329-
BlockImportError(BlockImportErrorKind::Other(s), _) => UtilError::from(s).into(),
330326
_ => ErrorKind::Msg(format!("other block import error: {:?}", err)).into(),
331327
}
332328
}

ethcore/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ extern crate patricia_trie_ethereum as ethtrie;
100100
extern crate triehash;
101101
extern crate ansi_term;
102102
extern crate unexpected;
103-
extern crate util_error;
104103
extern crate snappy;
105104
extern crate ethabi;
106105
extern crate rustc_hex;

ethcore/src/snapshot/service.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use io::IoChannel;
3737

3838
use ethereum_types::H256;
3939
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
40-
use util_error::UtilError;
4140
use bytes::Bytes;
4241
use journaldb::Algorithm;
4342
use snappy;
@@ -621,7 +620,7 @@ impl Service {
621620

622621
match is_done {
623622
true => {
624-
db.key_value().flush().map_err(UtilError::from)?;
623+
db.key_value().flush()?;
625624
drop(db);
626625
return self.finalize_restoration(&mut *restoration);
627626
},
@@ -634,7 +633,10 @@ impl Service {
634633
}
635634
}
636635
};
637-
result.and_then(|_| db.key_value().flush().map_err(|e| UtilError::from(e).into()))
636+
637+
result?;
638+
db.key_value().flush()?;
639+
Ok(())
638640
}
639641

640642
/// Feed a state chunk to be processed synchronously.

ethcore/src/state_db.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
//! State database abstraction. For more info, see the doc for `StateDB`
1818
19+
use std::collections::{VecDeque, HashSet};
20+
use std::io;
21+
use std::sync::Arc;
22+
1923
use bloom_journal::{Bloom, BloomJournal};
2024
use byteorder::{LittleEndian, ByteOrder};
2125
use db::COL_ACCOUNT_BLOOM;
@@ -30,9 +34,6 @@ use lru_cache::LruCache;
3034
use memory_cache::MemoryLruCache;
3135
use parking_lot::Mutex;
3236
use state::{self, Account};
33-
use std::collections::{VecDeque, HashSet};
34-
use std::sync::Arc;
35-
use util_error::UtilError;
3637

3738
/// Value used to initialize bloom bitmap size.
3839
///
@@ -181,7 +182,7 @@ impl StateDB {
181182
}
182183

183184
/// Commit blooms journal to the database transaction
184-
pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> Result<(), UtilError> {
185+
pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> io::Result<()> {
185186
assert!(journal.hash_functions <= 255);
186187
batch.put(COL_ACCOUNT_BLOOM, ACCOUNT_BLOOM_HASHCOUNT_KEY, &[journal.hash_functions as u8]);
187188
let mut key = [0u8; 8];
@@ -196,7 +197,7 @@ impl StateDB {
196197
}
197198

198199
/// Journal all recent operations under the given era and ID.
199-
pub fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
200+
pub fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> io::Result<u32> {
200201
{
201202
let mut bloom_lock = self.account_bloom.lock();
202203
Self::commit_bloom(batch, bloom_lock.drain_journal())?;
@@ -209,7 +210,7 @@ impl StateDB {
209210

210211
/// Mark a given candidate from an ancient era as canonical, enacting its removals from the
211212
/// backing database and reverting any non-canonical historical commit's insertions.
212-
pub fn mark_canonical(&mut self, batch: &mut DBTransaction, end_era: u64, canon_id: &H256) -> Result<u32, UtilError> {
213+
pub fn mark_canonical(&mut self, batch: &mut DBTransaction, end_era: u64, canon_id: &H256) -> io::Result<u32> {
213214
self.db.mark_canonical(batch, end_era, canon_id)
214215
}
215216

util/error/Cargo.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

util/error/src/lib.rs

Lines changed: 0 additions & 71 deletions
This file was deleted.

util/journaldb/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ memorydb = { version = "0.2.0", path = "../memorydb" }
1717
parking_lot = "0.6"
1818
plain_hasher = { path = "../plain_hasher" }
1919
rlp = { path = "../rlp" }
20-
util-error = { path = "../error" }
2120

2221
[dev-dependencies]
2322
ethcore-logger = { path = "../../logger" }

util/journaldb/src/archivedb.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
1919
use std::collections::HashMap;
2020
use std::collections::hash_map::Entry;
21+
use std::io;
2122
use std::sync::Arc;
2223

2324
use bytes::Bytes;
24-
use error::{BaseDataError, UtilError};
2525
use ethereum_types::H256;
2626
use hashdb::*;
2727
use keccak_hasher::KeccakHasher;
2828
use kvdb::{KeyValueDB, DBTransaction};
2929
use rlp::{encode, decode};
30-
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY};
30+
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, error_key_already_exists, error_negatively_reference_hash};
3131
use super::memorydb::*;
3232
use traits::JournalDB;
3333

@@ -127,7 +127,7 @@ impl JournalDB for ArchiveDB {
127127
self.latest_era.is_none()
128128
}
129129

130-
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, _id: &H256) -> Result<u32, UtilError> {
130+
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, _id: &H256) -> io::Result<u32> {
131131
let mut inserts = 0usize;
132132
let mut deletes = 0usize;
133133

@@ -150,28 +150,28 @@ impl JournalDB for ArchiveDB {
150150
Ok((inserts + deletes) as u32)
151151
}
152152

153-
fn mark_canonical(&mut self, _batch: &mut DBTransaction, _end_era: u64, _canon_id: &H256) -> Result<u32, UtilError> {
153+
fn mark_canonical(&mut self, _batch: &mut DBTransaction, _end_era: u64, _canon_id: &H256) -> io::Result<u32> {
154154
// keep everything! it's an archive, after all.
155155
Ok(0)
156156
}
157157

158-
fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32, UtilError> {
158+
fn inject(&mut self, batch: &mut DBTransaction) -> io::Result<u32> {
159159
let mut inserts = 0usize;
160160
let mut deletes = 0usize;
161161

162162
for i in self.overlay.drain() {
163163
let (key, (value, rc)) = i;
164164
if rc > 0 {
165165
if self.backing.get(self.column, &key)?.is_some() {
166-
return Err(BaseDataError::AlreadyExists(key).into());
166+
return Err(error_key_already_exists(&key));
167167
}
168168
batch.put(self.column, &key, &value);
169169
inserts += 1;
170170
}
171171
if rc < 0 {
172172
assert!(rc == -1);
173173
if self.backing.get(self.column, &key)?.is_none() {
174-
return Err(BaseDataError::NegativelyReferencedHash(key).into());
174+
return Err(error_negatively_reference_hash(&key));
175175
}
176176
batch.delete(self.column, &key);
177177
deletes += 1;

0 commit comments

Comments
 (0)