From 34af5797df675912d9a78ea6a673b8a535ce1f91 Mon Sep 17 00:00:00 2001 From: Matthias Kandora Date: Fri, 27 Aug 2021 16:32:15 +0200 Subject: [PATCH] Fix/remove riker from utils (#252) * fix: remove stronghold-utils from covector * fix: remove remaining riker dependency * fix: add changes doc * fix: add stronghold-utils as package --- .changes/config.json | 16 +++++++------- .changes/utils.md | 5 +++++ utils/Cargo.toml | 2 -- utils/src/ask.rs | 52 -------------------------------------------- utils/src/lib.rs | 2 -- 5 files changed, 13 insertions(+), 64 deletions(-) create mode 100644 .changes/utils.md delete mode 100644 utils/src/ask.rs diff --git a/.changes/config.json b/.changes/config.json index 6dd981444..92b93c090 100644 --- a/.changes/config.json +++ b/.changes/config.json @@ -79,13 +79,6 @@ "path": "./engine/runtime/", "manager": "rust" }, - "stronghold-utils": { - "path": "./utils/", - "manager": "rust", - "dependencies": [ - "stronghold-derive" - ] - }, "stronghold-engine": { "path": "./engine/", "manager": "rust", @@ -94,6 +87,13 @@ "stronghold-utils" ] }, + "stronghold-utils": { + "path": "./utils/", + "manager": "rust", + "dependencies": [ + "stronghold-derive" + ] + }, "stronghold-p2p": { "path": "./p2p/", "manager": "rust", @@ -120,4 +120,4 @@ ] } } -} +} \ No newline at end of file diff --git a/.changes/utils.md b/.changes/utils.md new file mode 100644 index 000000000..f07777094 --- /dev/null +++ b/.changes/utils.md @@ -0,0 +1,5 @@ +--- +"stronghold-utils": patch +--- + +- remove riker as dependency from utils. \ No newline at end of file diff --git a/utils/Cargo.toml b/utils/Cargo.toml index bbd1bd302..b6d6f47eb 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -12,9 +12,7 @@ homepage = "https://stronghold.docs.iota.org" repository = "https://github.com/iotaledger/stronghold.rs" [dependencies] -futures = "0.3" rand = "0.8.3" -riker = "0.4" [dependencies.stronghold-derive] path = "../derive" diff --git a/utils/src/ask.rs b/utils/src/ask.rs deleted file mode 100644 index 080cd91a1..000000000 --- a/utils/src/ask.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2020-2021 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use riker::actors::*; - -use std::sync::{Arc, Mutex}; - -use futures::{ - channel::oneshot::{channel, Sender as ChannelSender}, - future::RemoteHandle, - FutureExt, -}; - -// riker ask pattern -pub fn ask(ctx: &Ctx, receiver: &T, msg: Msg) -> RemoteHandle -where - Msg: Message, - R: Message, - Ctx: TmpActorRefFactory + Run, - T: Tell, -{ - let (tx, rx) = channel::(); - let tx = Arc::new(Mutex::new(Some(tx))); - - let props = Props::new_from_args(Box::new(AskActor::boxed), tx); - let actor = ctx.tmp_actor_of_props(props).unwrap(); - receiver.tell(msg, Some(actor.into())); - - ctx.run(rx.map(|r| r.unwrap())).unwrap() -} - -struct AskActor { - tx: Arc>>>, -} - -impl AskActor { - fn boxed(tx: Arc>>>) -> BoxActor { - let ask = AskActor { tx }; - Box::new(ask) - } -} - -impl Actor for AskActor { - type Msg = Msg; - - fn recv(&mut self, ctx: &Context, msg: Msg, _: Sender) { - if let Ok(mut tx) = self.tx.lock() { - tx.take().unwrap().send(msg).unwrap(); - } - ctx.stop(&ctx.myself); - } -} diff --git a/utils/src/lib.rs b/utils/src/lib.rs index 567882d1c..0824cf738 100644 --- a/utils/src/lib.rs +++ b/utils/src/lib.rs @@ -1,7 +1,5 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -mod ask; pub mod test_utils; -pub use ask::ask; pub use stronghold_derive::{GuardDebug, RequestPermissions};