Hi Mostafa,
The problem is that you're creating an independent
futures::executor::LocalPool inside the method and then blocking on it.
That never yields control back to the main event loop.
It should work if you set things up like this:
impl executor::Server for ExecutorImpl {
fn execute(
&mut self,
params: executor::ExecuteParams,
mut results: executor::ExecuteResults,
) -> Promise<(), Error> {
let provider = pry!(pry!(params.get()).get_provider());
Promise::from_future(async move {
let storage_req = provider.get_storage_request();
let storage_result = storage_req.send().promise.await?;
let storage = storage_result.get()?.get_storage()?;
// use storage here ...
println!("storage = {}", storage);
Ok(())
})
}
}
On Sat, May 9, 2020 at 10:44 AM Mostafa Sedaghat joo <
[email protected]> wrote:
> Hello guys,
>
>
> I hope you all are doing well
>
>
> I am struggling with an issue for more than a week, I decided to ask you
> if you can help me. Currently I am working on a project for executing smart
> contracts based on Web-Assembly for Blockchains. The project is named
> Durian and you can check it here: https://github.com/b00f/durian
>
> Durian simply provides an interface for blockchains to execute smart
> contracts. A client can ask the Durian: "Hey please execute this smart
> contract for me", and then Durian tries to execute it. During the
> execution, Durian might ask the client to provide some information:
> "Blockchain please give me some information like storage, account, etc."
> Finally the execution will return with the final result.
>
> Locally everything works fine. I wanted to make it as a web service. So I
> have two choices:
>
> Pull model: Client asks blockchain to execute the smart contract and in a
> loop he asks Durian: Hey Durian do you need anything that I can provide for
> you”, Durian might say:” Yes please, Give me this storage” and so on. In
> this case I can use gRPC or CapnProto, Both works fine.
>
> Push model: Client asks Durian to execute a smart contract, during the
> execution, Durian calls client several times to get some information. Like
> storage as an example. The point is that calling the client happens inside
> the execution call.
> [image: durian_flows.png]
>
> I decided to implement the second model using CapnP Proto. I tried and
> tried and again tried but unfortunately I failed. The difference between
> this model and PubSub is in the PubSub model, the publisher and the
> subscriber are running independently.
>
> First of all I want to know do you think the Push model is something
> feasible and practical?
>
> If yes, Why can't I call the client from the server?
> [image: durian_diagram.png]
>
> I have attached my work. I made it as simple as I could. I removed the
> Durian from it and just added only one method for getting storage. I want
> to get storage value from the client during the execution.
>
> I really appreciate it if you can take a look at it and let me know which
> part I was doing wrong?
>
> In advance I would like to thank you.
>
>
> Regards,
>
> Mostafa
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/capnproto/CAJr8eKtwcLa3f7tGiPvM39bQ8S7gqFptDZ1Zw47yRJHzqNr5DQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/capnproto/CAJr8eKtwcLa3f7tGiPvM39bQ8S7gqFptDZ1Zw47yRJHzqNr5DQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/capnproto/CABR6rW_Y1-tskW7zUvNWJ5_Oe3mQXzgRm5Jt%3DDaHAzvYwxgqSQ%40mail.gmail.com.