diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index fb512d91a..dc5d8c081 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -37,7 +37,7 @@ use ethcore::filter::Filter as EthcoreFilter; use self::ethash::SeedHashCompute; use v1::traits::Eth; use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, OptionalValue, Index, Filter, Log, Receipt}; -use v1::impls::dispatch_transaction; +use v1::impls::{dispatch_transaction, error_codes}; use serde; /// Eth rpc implementation. @@ -218,13 +218,9 @@ fn from_params_default_third(params: Params) -> Result<(F1, F2, BlockNum } } -// must be in range [-32099, -32000] -const UNSUPPORTED_REQUEST_CODE: i64 = -32000; -const NO_WORK_CODE: i64 = -32001; - fn make_unsupported_err() -> Error { Error { - code: ErrorCode::ServerError(UNSUPPORTED_REQUEST_CODE), + code: ErrorCode::ServerError(error_codes::UNSUPPORTED_REQUEST_CODE), message: "Unsupported request.".into(), data: None } @@ -232,7 +228,7 @@ fn make_unsupported_err() -> Error { fn no_work_err() -> Error { Error { - code: ErrorCode::ServerError(NO_WORK_CODE), + code: ErrorCode::ServerError(error_codes::NO_WORK_CODE), message: "Still syncing.".into(), data: None } diff --git a/rpc/src/v1/impls/mod.rs b/rpc/src/v1/impls/mod.rs index 03f4b34ed..8ea02b8b3 100644 --- a/rpc/src/v1/impls/mod.rs +++ b/rpc/src/v1/impls/mod.rs @@ -63,6 +63,15 @@ use util::rlp::encode; use util::bytes::ToPretty; use jsonrpc_core::{Error, ErrorCode, Value, to_value}; +mod error_codes { + // NOTE [ToDr] Codes from [-32099, -32000] + pub const UNSUPPORTED_REQUEST_CODE: i64 = -32000; + pub const NO_WORK_CODE: i64 = -32001; + pub const UNKNOWN_ERROR: i64 = -32002; + pub const TRANSACTION_ERROR: i64 = -32010; + pub const ACCOUNT_LOCKED: i64 = -32020; +} + fn dispatch_transaction(client: &C, miner: &M, signed_transaction: SignedTransaction) -> Result where C: MiningBlockChainClient, M: MinerService { let hash = signed_transaction.hash(); @@ -102,13 +111,6 @@ fn sign_and_dispatch(client: &C, miner: &M, request: TransactionRequest, s dispatch_transaction(&*client, &*miner, signed_transaction) } -mod error_codes { - // NOTE [ToDr] Codes from -32000 to -32099 - pub const UNKNOWN_ERROR: i64 = -32002; - pub const TRANSACTION_ERROR: i64 = -32010; - pub const ACCOUNT_LOCKED: i64 = -32020; -} - fn transaction_error(error: EthcoreError) -> Error { use ethcore::error::TransactionError::*;