diff --git a/sdk/src/client/node_api/core/routes.rs b/sdk/src/client/node_api/core/routes.rs index 76b7011579..f6ad04fc61 100644 --- a/sdk/src/client/node_api/core/routes.rs +++ b/sdk/src/client/node_api/core/routes.rs @@ -156,7 +156,7 @@ impl ClientInner { let block_dto = BlockDto::from(block); let response = self - .post_request_json::(PATH, serde_json::to_value(block_dto)?) + .post_request::(PATH, serde_json::to_value(block_dto)?) .await?; Ok(response.block_id) @@ -167,14 +167,8 @@ impl ClientInner { pub async fn post_block_raw(&self, block: &Block) -> Result { const PATH: &str = "api/core/v3/blocks"; - let timeout = self.get_timeout().await; - - // TODO add Client::post_request_bytes let response = self - .node_manager - .read() - .await - .post_request_bytes::(PATH, timeout, &block.pack_to_vec()) + .post_request_bytes::(PATH, &block.pack_to_vec()) .await?; Ok(response.block_id) diff --git a/sdk/src/client/node_api/plugin/mod.rs b/sdk/src/client/node_api/plugin/mod.rs index e29edc92e3..a5c3d7d62c 100644 --- a/sdk/src/client/node_api/plugin/mod.rs +++ b/sdk/src/client/node_api/plugin/mod.rs @@ -31,7 +31,7 @@ impl ClientInner { match req_method { Ok(Method::GET) => self.get_request(&path, None, false, false).await, - Ok(Method::POST) => self.post_request_json(&path, request_object.into()).await, + Ok(Method::POST) => self.post_request(&path, request_object.into()).await, _ => Err(crate::client::Error::Node( crate::client::node_api::error::Error::NotSupported(method.to_string()), )), diff --git a/sdk/src/client/node_manager/mod.rs b/sdk/src/client/node_manager/mod.rs index 99c451ba67..08c4e364f9 100644 --- a/sdk/src/client/node_manager/mod.rs +++ b/sdk/src/client/node_manager/mod.rs @@ -84,9 +84,17 @@ impl ClientInner { request.await } - pub(crate) async fn post_request_json(&self, path: &str, json: Value) -> Result { + pub(crate) async fn post_request(&self, path: &str, json: Value) -> Result { let node_manager = self.node_manager.read().await; - let request = node_manager.post_request_json(path, self.get_timeout().await, json); + let request = node_manager.post_request(path, self.get_timeout().await, json); + #[cfg(not(target_family = "wasm"))] + let request = request.rate_limit(&self.request_pool); + request.await + } + + pub(crate) async fn post_request_bytes(&self, path: &str, body: &[u8]) -> Result { + let node_manager = self.node_manager.read().await; + let request = node_manager.post_request_bytes(path, self.get_timeout().await, body); #[cfg(not(target_family = "wasm"))] let request = request.rate_limit(&self.request_pool); request.await @@ -340,7 +348,7 @@ impl NodeManager { Err(error.unwrap()) } - pub(crate) async fn post_request_json( + pub(crate) async fn post_request( &self, path: &str, timeout: Duration,