-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(jsonrpc): cleanup adversarial-primitives (#6851)
Tracking issue: #6850 Cleanup feature flags in `near-jsonrpc-adversarial-primitives`.
- Loading branch information
Showing
3 changed files
with
19 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
#[cfg(feature = "ser_de")] | ||
use near_jsonrpc_primitives::errors::RpcError; | ||
use near_network_primitives::types::{Edge, SimpleEdge}; | ||
use near_primitives::network::PeerId; | ||
#[cfg(feature = "ser_de")] | ||
use serde::Deserialize; | ||
#[cfg(feature = "ser_de")] | ||
use serde_json::Value; | ||
|
||
#[cfg_attr(feature = "ser_de", derive(Deserialize))] | ||
#[cfg_attr(feature = "test_features", derive(Deserialize))] | ||
#[cfg_attr(feature = "deepsize_feature", derive(deepsize::DeepSizeOf))] | ||
pub struct SetRoutingTableRequest { | ||
pub add_edges: Option<Vec<Edge>>, | ||
pub remove_edges: Option<Vec<SimpleEdge>>, | ||
pub prune_edges: Option<bool>, | ||
} | ||
|
||
#[cfg(feature = "ser_de")] | ||
#[cfg(feature = "test_features")] | ||
impl SetRoutingTableRequest { | ||
pub fn parse(value: Option<Value>) -> Result<Self, RpcError> { | ||
pub fn parse( | ||
value: Option<serde_json::Value>, | ||
) -> Result<Self, near_jsonrpc_primitives::errors::RpcError> { | ||
if let Some(value) = value { | ||
serde_json::from_value(value) | ||
.map_err(|err| RpcError::parse_error(format!("Error {:?}", err))) | ||
serde_json::from_value(value).map_err(|err| { | ||
near_jsonrpc_primitives::errors::RpcError::parse_error(format!("Error {:?}", err)) | ||
}) | ||
} else { | ||
Err(RpcError::parse_error("Require at least one parameter".to_owned())) | ||
Err(near_jsonrpc_primitives::errors::RpcError::parse_error( | ||
"Require at least one parameter".to_owned(), | ||
)) | ||
} | ||
} | ||
} | ||
|
||
#[cfg_attr(feature = "ser_de", derive(Deserialize))] | ||
#[derive(Deserialize)] | ||
pub struct SetAdvOptionsRequest { | ||
pub disable_edge_signature_verification: Option<bool>, | ||
pub disable_edge_propagation: Option<bool>, | ||
pub disable_edge_pruning: Option<bool>, | ||
} | ||
|
||
#[cfg_attr(feature = "ser_de", derive(Deserialize))] | ||
#[derive(Deserialize)] | ||
pub struct StartRoutingTableSyncRequest { | ||
pub peer_id: PeerId, | ||
} |
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