address match style concerns
This commit is contained in:
parent
3cba91bdd5
commit
5d997ef099
@ -64,33 +64,18 @@ impl fmt::Display for TransactionError {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
use self::TransactionError::*;
|
use self::TransactionError::*;
|
||||||
let msg = match *self {
|
let msg = match *self {
|
||||||
AlreadyImported => {
|
AlreadyImported => "Already imported".into(),
|
||||||
"Already imported".into()
|
Old => "No longer valid".into(),
|
||||||
}
|
TooCheapToReplace => "Gas price too low to replace".into(),
|
||||||
Old => {
|
LimitReached => "Transaction limit reached".into(),
|
||||||
"No longer valid".into()
|
InsufficientGasPrice { minimal, got } =>
|
||||||
}
|
format!("Insufficient gas price. Min={}, Given={}", minimal, got),
|
||||||
TooCheapToReplace => {
|
InsufficientBalance { balance, cost } =>
|
||||||
"Gas price too low to replace".into()
|
|
||||||
}
|
|
||||||
LimitReached => {
|
|
||||||
"Transaction limit reached".into()
|
|
||||||
}
|
|
||||||
InsufficientGasPrice { minimal, got } => {
|
|
||||||
format!("Insufficient gas price. Min={}, Given={}",
|
|
||||||
minimal, got)
|
|
||||||
}
|
|
||||||
InsufficientBalance { balance, cost } => {
|
|
||||||
format!("Insufficient balance for transaction. Balance={}, Cost={}",
|
format!("Insufficient balance for transaction. Balance={}, Cost={}",
|
||||||
balance, cost)
|
balance, cost),
|
||||||
}
|
GasLimitExceeded { limit, got } =>
|
||||||
GasLimitExceeded { limit, got } => {
|
format!("Gas limit exceeded. Limit={}, Given={}", limit, got),
|
||||||
format!("Gas limit exceeded. Limit={}, Given={}",
|
InvalidGasLimit(ref err) => format!("Invalid gas limit. {}", err),
|
||||||
limit, got)
|
|
||||||
}
|
|
||||||
InvalidGasLimit(ref err) => {
|
|
||||||
format!("Invalid gas limit. {}", err)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
f.write_fmt(format_args!("Transaction error ({})", msg))
|
f.write_fmt(format_args!("Transaction error ({})", msg))
|
||||||
@ -163,84 +148,32 @@ impl fmt::Display for BlockError {
|
|||||||
use self::BlockError::*;
|
use self::BlockError::*;
|
||||||
|
|
||||||
let msg = match *self {
|
let msg = match *self {
|
||||||
TooManyUncles(ref oob) => {
|
TooManyUncles(ref oob) => format!("Block has too many uncles. {}", oob),
|
||||||
format!("Block has too many uncles. {}", oob)
|
ExtraDataOutOfBounds(ref oob) => format!("Extra block data too long. {}", oob),
|
||||||
}
|
InvalidSealArity(ref mis) => format!("Block seal in incorrect format: {}", mis),
|
||||||
ExtraDataOutOfBounds(ref oob) => {
|
TooMuchGasUsed(ref oob) => format!("Block has too much gas used. {}", oob),
|
||||||
format!("Extra block data too long. {}", oob)
|
InvalidUnclesHash(ref mis) => format!("Block has invalid uncles hash: {}", mis),
|
||||||
}
|
UncleTooOld(ref oob) => format!("Uncle block is too old. {}", oob),
|
||||||
InvalidSealArity(ref mis) => {
|
UncleIsBrother(ref oob) => format!("Uncle from same generation as block. {}", oob),
|
||||||
format!("Block seal in incorrect format: {}", mis)
|
UncleInChain(ref hash) => format!("Uncle {} already in chain", hash),
|
||||||
}
|
UncleParentNotInChain(ref hash) => format!("Uncle {} has a parent not in the chain", hash),
|
||||||
TooMuchGasUsed(ref oob) => {
|
InvalidStateRoot(ref mis) => format!("Invalid state root in header: {}", mis),
|
||||||
format!("Block has too much gas used. {}", oob)
|
InvalidGasUsed(ref mis) => format!("Invalid gas used in header: {}", mis),
|
||||||
}
|
InvalidTransactionsRoot(ref mis) => format!("Invalid transactions root in header: {}", mis),
|
||||||
InvalidUnclesHash(ref mis) => {
|
DifficultyOutOfBounds(ref oob) => format!("Invalid block difficulty: {}", oob),
|
||||||
format!("Block has invalid uncles hash: {}", mis)
|
InvalidDifficulty(ref mis) => format!("Invalid block difficulty: {}", mis),
|
||||||
}
|
MismatchedH256SealElement(ref mis) => format!("Seal element out of bounds: {}", mis),
|
||||||
UncleTooOld(ref oob) => {
|
InvalidProofOfWork(ref oob) => format!("Block has invalid PoW: {}", oob),
|
||||||
format!("Uncle block is too old. {}", oob)
|
InvalidSeal => "Block has invalid seal.".into(),
|
||||||
}
|
InvalidGasLimit(ref oob) => format!("Invalid gas limit: {}", oob),
|
||||||
UncleIsBrother(ref oob) => {
|
InvalidReceiptsRoot(ref mis) => format!("Invalid receipts trie root in header: {}", mis),
|
||||||
format!("Uncle from same generation as block. {}", oob)
|
InvalidTimestamp(ref oob) => format!("Invalid timestamp in header: {}", oob),
|
||||||
}
|
InvalidLogBloom(ref oob) => format!("Invalid log bloom in header: {}", oob),
|
||||||
UncleInChain(ref hash) => {
|
InvalidParentHash(ref mis) => format!("Invalid parent hash: {}", mis),
|
||||||
format!("Uncle {} already in chain", hash)
|
InvalidNumber(ref mis) => format!("Invalid number in header: {}", mis),
|
||||||
}
|
RidiculousNumber(ref oob) => format!("Implausible block number. {}", oob),
|
||||||
UncleParentNotInChain(ref hash) => {
|
UnknownParent(ref hash) => format!("Unknown parent: {}", hash),
|
||||||
format!("Uncle {} has a parent not in the chain", hash)
|
UnknownUncleParent(ref hash) => format!("Unknown uncle parent: {}", hash),
|
||||||
}
|
|
||||||
InvalidStateRoot(ref mis) => {
|
|
||||||
format!("Invalid state root in header: {}", mis)
|
|
||||||
}
|
|
||||||
InvalidGasUsed(ref mis) => {
|
|
||||||
format!("Invalid gas used in header: {}", mis)
|
|
||||||
}
|
|
||||||
InvalidTransactionsRoot(ref mis) => {
|
|
||||||
format!("Invalid transactions root in header: {}", mis)
|
|
||||||
}
|
|
||||||
DifficultyOutOfBounds(ref oob) => {
|
|
||||||
format!("Invalid block difficulty: {}", oob)
|
|
||||||
}
|
|
||||||
InvalidDifficulty(ref mis) => {
|
|
||||||
format!("Invalid block difficulty: {}", mis)
|
|
||||||
}
|
|
||||||
MismatchedH256SealElement(ref mis) => {
|
|
||||||
format!("Seal element out of bounds: {}", mis)
|
|
||||||
}
|
|
||||||
InvalidProofOfWork(ref oob) => {
|
|
||||||
format!("Block has invalid PoW: {}", oob)
|
|
||||||
}
|
|
||||||
InvalidSeal => {
|
|
||||||
"Block has invalid seal.".into()
|
|
||||||
}
|
|
||||||
InvalidGasLimit(ref oob) => {
|
|
||||||
format!("Invalid gas limit: {}", oob)
|
|
||||||
}
|
|
||||||
InvalidReceiptsRoot(ref mis) => {
|
|
||||||
format!("Invalid receipts trie root in header: {}", mis)
|
|
||||||
}
|
|
||||||
InvalidTimestamp(ref oob) => {
|
|
||||||
format!("Invalid timestamp in header: {}", oob)
|
|
||||||
}
|
|
||||||
InvalidLogBloom(ref oob) => {
|
|
||||||
format!("Invalid log bloom in header: {}", oob)
|
|
||||||
}
|
|
||||||
InvalidParentHash(ref mis) => {
|
|
||||||
format!("Invalid parent hash: {}", mis)
|
|
||||||
}
|
|
||||||
InvalidNumber(ref mis) => {
|
|
||||||
format!("Invalid number in header: {}", mis)
|
|
||||||
}
|
|
||||||
RidiculousNumber(ref oob) => {
|
|
||||||
format!("Implausible block number. {}", oob)
|
|
||||||
}
|
|
||||||
UnknownParent(ref hash) => {
|
|
||||||
format!("Unknown parent: {}", hash)
|
|
||||||
}
|
|
||||||
UnknownUncleParent(ref hash) => {
|
|
||||||
format!("Unknown uncle parent: {}", hash)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
f.write_fmt(format_args!("Block error ({})", msg))
|
f.write_fmt(format_args!("Block error ({})", msg))
|
||||||
@ -260,16 +193,10 @@ pub enum ImportError {
|
|||||||
|
|
||||||
impl fmt::Display for ImportError {
|
impl fmt::Display for ImportError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let msg = match self {
|
let msg = match *self {
|
||||||
&ImportError::AlreadyInChain => {
|
ImportError::AlreadyInChain => "block already in chain",
|
||||||
"block already in chain"
|
ImportError::AlreadyQueued => "block already in the block queue",
|
||||||
}
|
ImportError::KnownBad => "block known to be bad",
|
||||||
&ImportError::AlreadyQueued => {
|
|
||||||
"block already in the block queue"
|
|
||||||
}
|
|
||||||
&ImportError::KnownBad => {
|
|
||||||
"block known to be bad"
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
f.write_fmt(format_args!("Block import error ({})", msg))
|
f.write_fmt(format_args!("Block import error ({})", msg))
|
||||||
@ -308,15 +235,10 @@ impl fmt::Display for Error {
|
|||||||
Error::Execution(ref err) => f.write_fmt(format_args!("{}", err)),
|
Error::Execution(ref err) => f.write_fmt(format_args!("{}", err)),
|
||||||
Error::Transaction(ref err) => f.write_fmt(format_args!("{}", err)),
|
Error::Transaction(ref err) => f.write_fmt(format_args!("{}", err)),
|
||||||
Error::Import(ref err) => f.write_fmt(format_args!("{}", err)),
|
Error::Import(ref err) => f.write_fmt(format_args!("{}", err)),
|
||||||
Error::UnknownEngineName(ref name) => {
|
Error::UnknownEngineName(ref name) =>
|
||||||
f.write_fmt(format_args!("Unknown engine name ({})", name))
|
f.write_fmt(format_args!("Unknown engine name ({})", name)),
|
||||||
}
|
Error::PowHashInvalid => f.write_str("Invalid or out of date PoW hash."),
|
||||||
Error::PowHashInvalid => {
|
Error::PowInvalid => f.write_str("Invalid nonce or mishash"),
|
||||||
f.write_str("Invalid or out of date PoW hash.")
|
|
||||||
}
|
|
||||||
Error::PowInvalid => {
|
|
||||||
f.write_str("Invalid nonce or mishash")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,11 @@ pub enum BaseDataError {
|
|||||||
|
|
||||||
impl fmt::Display for BaseDataError {
|
impl fmt::Display for BaseDataError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
BaseDataError::NegativelyReferencedHash(hash) => {
|
BaseDataError::NegativelyReferencedHash(hash) =>
|
||||||
f.write_fmt(format_args!("Entry {} removed from database more times \
|
f.write_fmt(format_args!("Entry {} removed from database more times \
|
||||||
than it was added.", hash))
|
than it was added.", hash)),
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,18 +115,10 @@ pub struct OutOfBounds<T: fmt::Debug> {
|
|||||||
impl<T: fmt::Debug + fmt::Display> fmt::Display for OutOfBounds<T> {
|
impl<T: fmt::Debug + fmt::Display> fmt::Display for OutOfBounds<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let msg = match (self.min.as_ref(), self.max.as_ref()) {
|
let msg = match (self.min.as_ref(), self.max.as_ref()) {
|
||||||
(Some(min), Some(max)) => {
|
(Some(min), Some(max)) => format!("Min={}, Max={}", min, max),
|
||||||
format!("Min={}, Max={}", min, max)
|
(Some(min), _) => format!("Min={}", min),
|
||||||
}
|
(_, Some(max)) => format!("Max={}", max),
|
||||||
(Some(min), _) => {
|
(None, None) => "".into(),
|
||||||
format!("Min={}", min)
|
|
||||||
}
|
|
||||||
(_, Some(max)) => {
|
|
||||||
format!("Max={}", max)
|
|
||||||
}
|
|
||||||
(None, None) => {
|
|
||||||
"".into()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
f.write_fmt(format_args!("Value {} out of bounds. {}", self.found, msg))
|
f.write_fmt(format_args!("Value {} out of bounds. {}", self.found, msg))
|
||||||
|
Loading…
Reference in New Issue
Block a user