JournalDB inject (#1806)

* add inject to journaldb

* adjust docs

* add test; fix refcounteddb impl

* fewer panics, fail on invalid insertions or deletions
This commit is contained in:
Robert Habermeier
2016-08-03 16:34:32 +02:00
committed by Gav Wood
parent c5ffb5af79
commit 8c88e2a8cc
6 changed files with 188 additions and 18 deletions

View File

@@ -28,14 +28,17 @@ use hash::H256;
pub enum BaseDataError {
/// An entry was removed more times than inserted.
NegativelyReferencedHash(H256),
/// A committed value was inserted more than once.
AlreadyExists(H256),
}
impl fmt::Display for BaseDataError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BaseDataError::NegativelyReferencedHash(hash) =>
f.write_fmt(format_args!("Entry {} removed from database more times \
than it was added.", hash)),
write!(f, "Entry {} removed from database more times than it was added.", hash),
BaseDataError::AlreadyExists(hash) =>
write!(f, "Committed key already exists in database: {}", hash),
}
}
}