Skip to content

Commit

Permalink
Fix unban arguments taken in api-private in intend to be serializ…
Browse files Browse the repository at this point in the history
…able by `jsonrpc-core-client`
  • Loading branch information
yvan-sraka committed Oct 5, 2021
1 parent 91e526b commit 023677e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions api-private/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ displaydoc = "0.2"
jsonrpc-core = "18.0.0"
jsonrpc-derive = "18.0.0"
jsonrpc-http-server = "18.0.0"
tokio = { version = "1.11", features = ["full"] }
thiserror = "1.0"
# custom modules
crypto = {path = "../crypto"}
api-dto = { path = "../api-dto" }
models = {path = "../models"}
crypto = {path = "../crypto"}
communication = {path = "../communication"}
consensus = {path = "../consensus"}
time = {path = "../time"}
models = {path = "../models"}
rpc-server = {path = "../rpc-server"}
thiserror = "1.0"

tokio = { version = "1.11", features = ["full"] }
time = {path = "../time"}
10 changes: 7 additions & 3 deletions api-private/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub trait MassaPrivate {
/// Unbans given ip addr
/// No confirmation to expect.
#[rpc(name = "unban")]
fn unban(&self, _: IpAddr) -> BoxFuture<Result<(), PrivateApiError>>;
fn unban(&self, _: Vec<IpAddr>) -> BoxFuture<Result<(), PrivateApiError>>;
}

impl ApiMassaPrivate {
Expand Down Expand Up @@ -162,9 +162,13 @@ impl MassaPrivate for ApiMassaPrivate {
Box::pin(closure())
}

fn unban(&self, ip: IpAddr) -> BoxFuture<Result<(), PrivateApiError>> {
fn unban(&self, ips: Vec<IpAddr>) -> BoxFuture<Result<(), PrivateApiError>> {
let network_command_sender = self.network_command_sender.clone();
let closure = async move || Ok(network_command_sender.unban(ip).await?);
let closure = async move || {
for ip in ips {
Ok(network_command_sender.unban(ip).await?)
}
};
Box::pin(closure())
}
}

0 comments on commit 023677e

Please sign in to comment.