-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
625 additions
and
761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
use serde_json::Value; | ||
|
||
use near_client_primitives::types::GetProtocolConfigError; | ||
use near_jsonrpc_primitives::errors::RpcParseError; | ||
use near_jsonrpc_primitives::types::config::RpcProtocolConfigRequest; | ||
use near_jsonrpc_primitives::types::config::{RpcProtocolConfigError, RpcProtocolConfigRequest}; | ||
use near_primitives::types::BlockReference; | ||
|
||
use super::{parse_params, RpcRequest}; | ||
use super::{parse_params, RpcFrom, RpcRequest}; | ||
|
||
impl RpcRequest for RpcProtocolConfigRequest { | ||
fn parse(value: Option<Value>) -> Result<Self, RpcParseError> { | ||
parse_params::<BlockReference>(value).map(|block_reference| Self { block_reference }) | ||
} | ||
} | ||
|
||
impl RpcFrom<actix::MailboxError> for RpcProtocolConfigError { | ||
fn rpc_from(error: actix::MailboxError) -> Self { | ||
Self::InternalError { error_message: error.to_string() } | ||
} | ||
} | ||
|
||
impl RpcFrom<GetProtocolConfigError> for RpcProtocolConfigError { | ||
fn rpc_from(error: GetProtocolConfigError) -> Self { | ||
match error { | ||
GetProtocolConfigError::UnknownBlock(error_message) => { | ||
Self::UnknownBlock { error_message } | ||
} | ||
GetProtocolConfigError::IOError(error_message) => Self::InternalError { error_message }, | ||
GetProtocolConfigError::Unreachable(ref error_message) => { | ||
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", error_message); | ||
crate::metrics::RPC_UNREACHABLE_ERROR_COUNT | ||
.with_label_values(&["RpcProtocolConfigError"]) | ||
.inc(); | ||
Self::InternalError { error_message: error.to_string() } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,40 @@ | ||
use serde_json::Value; | ||
|
||
use near_client_primitives::types::GetGasPriceError; | ||
use near_jsonrpc_primitives::errors::RpcParseError; | ||
use near_jsonrpc_primitives::types::gas_price::RpcGasPriceRequest; | ||
use near_jsonrpc_primitives::types::gas_price::{RpcGasPriceError, RpcGasPriceRequest}; | ||
use near_primitives::types::MaybeBlockId; | ||
|
||
use super::{parse_params, RpcRequest}; | ||
use super::{parse_params, RpcFrom, RpcRequest}; | ||
|
||
impl RpcRequest for RpcGasPriceRequest { | ||
fn parse(value: Option<Value>) -> Result<Self, RpcParseError> { | ||
parse_params::<(MaybeBlockId,)>(value).map(|(block_id,)| Self { block_id }) | ||
} | ||
} | ||
|
||
impl RpcFrom<actix::MailboxError> for RpcGasPriceError { | ||
fn rpc_from(error: actix::MailboxError) -> Self { | ||
Self::InternalError { error_message: error.to_string() } | ||
} | ||
} | ||
|
||
impl RpcFrom<GetGasPriceError> for RpcGasPriceError { | ||
fn rpc_from(error: GetGasPriceError) -> Self { | ||
match error { | ||
GetGasPriceError::UnknownBlock { error_message } => { | ||
Self::UnknownBlock { error_message } | ||
} | ||
GetGasPriceError::InternalError { error_message } => { | ||
Self::InternalError { error_message } | ||
} | ||
GetGasPriceError::Unreachable { ref error_message } => { | ||
tracing::warn!(target: "jsonrpc", "Unreachable error occurred: {}", error_message); | ||
crate::metrics::RPC_UNREACHABLE_ERROR_COUNT | ||
.with_label_values(&["RpcGasPriceError"]) | ||
.inc(); | ||
Self::InternalError { error_message: error.to_string() } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.