From 6dee006f05e8d21ce69f9c50078acbb444a0b8e3 Mon Sep 17 00:00:00 2001 From: Maxwell Koo Date: Sat, 2 Mar 2019 16:45:44 -0700 Subject: [PATCH 1/3] Implement Python wrapper for parity-clib and example --- parity-clib/Cargo.toml | 1 + parity-clib/examples/python/.gitignore | 1 + parity-clib/examples/python/README.md | 9 + parity-clib/examples/python/example.py | 39 +++++ parity-clib/examples/python/run.sh | 13 ++ parity-clib/python/.gitignore | 6 + parity-clib/python/parity/__init__.py | 121 ++++++++++++++ parity-clib/python/requirements.txt | 1 + parity-clib/python/setup.py | 39 +++++ parity-clib/src/lib.rs | 7 + parity-clib/src/python.rs | 219 +++++++++++++++++++++++++ 11 files changed, 456 insertions(+) create mode 100644 parity-clib/examples/python/.gitignore create mode 100644 parity-clib/examples/python/README.md create mode 100644 parity-clib/examples/python/example.py create mode 100755 parity-clib/examples/python/run.sh create mode 100644 parity-clib/python/.gitignore create mode 100644 parity-clib/python/parity/__init__.py create mode 100644 parity-clib/python/requirements.txt create mode 100644 parity-clib/python/setup.py create mode 100644 parity-clib/src/python.rs diff --git a/parity-clib/Cargo.toml b/parity-clib/Cargo.toml index f57e503dea6..b3d93c9b59d 100644 --- a/parity-clib/Cargo.toml +++ b/parity-clib/Cargo.toml @@ -14,6 +14,7 @@ futures = "0.1.6" jni = { version = "0.11", optional = true } panic_hook = { path = "../util/panic-hook" } parity-ethereum = { path = "../", default-features = false } +pyo3 = { version = "0.6.0-alpha.4", optional = true, features = ["extension-module"] } tokio = "0.1.11" tokio-current-thread = "0.1.3" diff --git a/parity-clib/examples/python/.gitignore b/parity-clib/examples/python/.gitignore new file mode 100644 index 00000000000..f7275bbbd03 --- /dev/null +++ b/parity-clib/examples/python/.gitignore @@ -0,0 +1 @@ +venv/ diff --git a/parity-clib/examples/python/README.md b/parity-clib/examples/python/README.md new file mode 100644 index 00000000000..66fbbe3368e --- /dev/null +++ b/parity-clib/examples/python/README.md @@ -0,0 +1,9 @@ +parity-clib: Python example +=================================== + +An example Python application to demonstrate how to use `pyo3` bindings to parity-ethereum. + +## How to compile and run + +1. Make sure you have python3 and python3-venv installed. +2. Run `run.sh` diff --git a/parity-clib/examples/python/example.py b/parity-clib/examples/python/example.py new file mode 100644 index 00000000000..7f41e02c68e --- /dev/null +++ b/parity-clib/examples/python/example.py @@ -0,0 +1,39 @@ +# Copyright 2019 Parity Technologies (UK) Ltd. +# This file is part of Parity. +# +# Parity is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Parity is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Parity. If not, see . + +from itertools import islice + +from parity import Parity + +# Set up Parity +opts = ["--no-ipc", "--jsonrpc-apis=all", "--chain", "kovan"] +p = Parity(opts) + +# Run a RPC query and print the results +query = "{\"method\":\"parity_versionInfo\",\"params\":[],\"id\":1,\"jsonrpc\":\"2.0\"}" +print('version info:', p.rpc_query(query)) + +# Subscribe to a websocket event +ws_query = "{\"method\":\"parity_subscribe\",\"params\":[\"parity_netPeers\"],\"id\":1,\"jsonrpc\":\"2.0\"}" +sub = p.subscribe_ws(ws_query) + +# Print the first 5 events received +for e in islice(sub.events, 5): + print('subscription event', e) + +# Unsubscribe to the event +sub.unsubscribe() + diff --git a/parity-clib/examples/python/run.sh b/parity-clib/examples/python/run.sh new file mode 100755 index 00000000000..92b4f614536 --- /dev/null +++ b/parity-clib/examples/python/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +mkdir -p ./venv +python3 -m venv ./venv + +source ./venv/bin/activate + +pushd ../../python +pip install -r requirements.txt +python setup.py install +popd + +python example.py diff --git a/parity-clib/python/.gitignore b/parity-clib/python/.gitignore new file mode 100644 index 00000000000..c7e0a9e8d6a --- /dev/null +++ b/parity-clib/python/.gitignore @@ -0,0 +1,6 @@ +*.so +*.egg-info/ +__pycache__/ +build/ +dist/ +venv/ diff --git a/parity-clib/python/parity/__init__.py b/parity-clib/python/parity/__init__.py new file mode 100644 index 00000000000..e09d6c3052e --- /dev/null +++ b/parity-clib/python/parity/__init__.py @@ -0,0 +1,121 @@ +# Copyright 2019 Parity Technologies (UK) Ltd. +# This file is part of Parity. +# +# Parity is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Parity is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Parity. If not, see . + +from queue import Queue + +# Rust extension module, see src/python.rs +import _parity + + +class _CallbackGenerator(object): + """Thin wrapper around a Queue which can be passed as a callback to _parity.* functions""" + + def __init__(self): + self.queue = Queue(maxsize=1) + + def __call__(self, value): + self.queue.put(value) + + def __iter__(self): + return self + + def __next__(self): + return self.get() + + def get(self, block=True, timeout=None): + """Get an element from the queue + + :param block: Should we block if no element available + :param timeout: Time to wait for new element + :return: Top item from the queue + :raises: queue.Empty + """ + return self.queue.get(block, timeout) + + def get_nowait(self): + """Get an element from the queue, do not wait. + + Equivalent to `get(False)` + + :return: Top item from the queue + :raises: queue.Empty + """ + return self.queue.get_nowait() + + +class Subscription(object): + """Encapsulates a subscription returned from subscribe_ws, allowing iteration over events and unsubscribing""" + + def __init__(self, sub, events): + self._sub = sub + self.events = events + + def unsubscribe(self): + """Unsubscribe from the underlying subscription""" + self._sub.unsubscribe() + + +class Parity(object): + """Connection to Parity client""" + + def __init__(self, options, logger_mode='', logger_file=''): + """Configure and start Parity + + :param options: Command line arguments to pass to Parity + :param logger_mode: Logger options to pass to Parity + :param logger_file: File to log to + """ + config = _parity.config_from_cli(options) + self.handle = _parity.build(config, logger_mode, logger_file) + + def rpc_query_cb(self, query, cb, timeout_ms=1000): + """Perform a RPC query, return immediately, cb will be invoked with the result asynchronously + + :param query: Query to perform + :param cb: Callback to invoke with results + :param timeout_ms: Timeout in milliseconds + """ + _parity.rpc_query(self.handle, query, timeout_ms, cb) + + def rpc_query(self, query, timeout_ms=1000): + """Perform a RPC query and return the result synchronously + + :param query: Query to perform + :param timeout_ms: Timeout in milliseconds + :return: Result of the rpc call + """ + cb = _CallbackGenerator() + self.rpc_query_cb(query, cb, timeout_ms) + return next(cb) + + def subscribe_ws_cb(self, query, cb): + """Subscribe to a websocket event, return immediately, cb will be invoked with events asynchronously + + :param query: Query to perform + :param cb: Callback to invoke with events + :return: Subscription handle + """ + return _parity.subscribe_ws(self.handle, query, cb) + + def subscribe_ws(self, query): + """Subscribe to a websocket event, return immediately, Subscription object can be iterated to receive events + + :param query: Query to perform + :return: Subscription object which can be iterated over to receive events + """ + cb = _CallbackGenerator() + sub = self.subscribe_ws_cb(query, cb) + return Subscription(sub, cb) diff --git a/parity-clib/python/requirements.txt b/parity-clib/python/requirements.txt new file mode 100644 index 00000000000..9b078202328 --- /dev/null +++ b/parity-clib/python/requirements.txt @@ -0,0 +1 @@ +setuptools-rust>=0.10.2 diff --git a/parity-clib/python/setup.py b/parity-clib/python/setup.py new file mode 100644 index 00000000000..c424a281cb4 --- /dev/null +++ b/parity-clib/python/setup.py @@ -0,0 +1,39 @@ +# Based off example setup.py from pyo3 +import sys + +from setuptools import setup +from setuptools.command.test import test as TestCommand +from setuptools_rust import RustExtension + +def get_py_version_cfgs(): + # For now each Cfg Py_3_X flag is interpreted as "at least 3.X" + version = sys.version_info[0:2] + + if version[0] == 2: + return ["--cfg=Py_2"] + + py3_min = 5 + out_cfg = [] + for minor in range(py3_min, version[1] + 1): + out_cfg.append("--cfg=Py_3_%d" % minor) + + return out_cfg + + +install_requires = [] +tests_require = install_requires + ["pytest", "pytest-benchmark"] + +setup( + name="parity-clib", + version="2.5.0", + packages=["parity"], + rust_extensions=[ + RustExtension( + "_parity", "../Cargo.toml", rustc_flags=get_py_version_cfgs() + ), + ], + install_requires=install_requires, + tests_require=tests_require, + include_package_data=True, + zip_safe=False, +) diff --git a/parity-clib/src/lib.rs b/parity-clib/src/lib.rs index bbb60ec2d26..9d6721a65e0 100644 --- a/parity-clib/src/lib.rs +++ b/parity-clib/src/lib.rs @@ -29,6 +29,13 @@ extern crate jni; #[cfg(feature = "jni")] mod java; +#[cfg(feature = "pyo3")] +#[macro_use] +extern crate pyo3; + +#[cfg(feature = "pyo3")] +mod python; + use std::ffi::CString; use std::os::raw::{c_char, c_void, c_int}; use std::{panic, ptr, slice, str, thread}; diff --git a/parity-clib/src/python.rs b/parity-clib/src/python.rs new file mode 100644 index 00000000000..d4fdcb47094 --- /dev/null +++ b/parity-clib/src/python.rs @@ -0,0 +1,219 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Parity Ethereum. + +// Parity Ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Ethereum. If not, see . + +use std::mem; +use std::os::raw::c_void; +use std::ptr; +use std::sync::Arc; + +use parity_ethereum::RunningClient; +use pyo3::exceptions::{RuntimeError, ValueError}; +use pyo3::prelude::*; +use pyo3::types::PyList; +use { + parity_config_destroy, parity_config_from_cli, parity_destroy, parity_rpc_worker, + parity_set_logger, parity_start, parity_unsubscribe_ws, parity_ws_worker, Callback, + ParityParams, +}; + +/// Handle to a Parity config created with parity_config_from_cli +#[pyclass] +struct ConfigHandle { + inner: *mut c_void, +} + +impl Drop for ConfigHandle { + fn drop(&mut self) { + if self.inner != ptr::null_mut() { + unsafe { + parity_config_destroy(self.inner); + } + } + } +} + +/// Handle to a Parity instance created with parity_start +#[pyclass] +struct ParityHandle { + inner: *mut c_void, +} + +impl Drop for ParityHandle { + fn drop(&mut self) { + if self.inner != ptr::null_mut() { + unsafe { + parity_destroy(self.inner); + } + } + } +} + +/// Handle to a subscription created with parity_ws_worker +#[pyclass] +struct SubscriptionHandle { + inner: *const c_void, +} + +#[pymethods] +impl SubscriptionHandle { + fn unsubscribe(&mut self) { + if self.inner != ptr::null_mut() { + unsafe { + parity_unsubscribe_ws(self.inner); + } + + self.inner = ptr::null_mut(); + } + } +} + +impl Drop for SubscriptionHandle { + fn drop(&mut self) { + self.unsubscribe() + } +} + +/// A Python callable which accepts a String value representing a RPC result or subscription event +struct PythonCallback(PyObject); + +impl PythonCallback { + fn new(callback: PyObject) -> Self { + Self(callback) + } +} + +impl Callback for PythonCallback { + fn call(&self, msg: &str) { + // Assume this is called from Rust, acquire GIL + let gil = Python::acquire_gil(); + let py = gil.python(); + + // Run our callback, and re-raise any exceptions that occur + if let Err(e) = self.0.call1(py, msg) { + e.restore(py); + } + } +} + +/// Generate a Parity config given a list of CLI options +#[pyfunction] +fn config_from_cli(_py: Python<'_>, cli: &PyList) -> PyResult { + let cli_len = cli.len(); + + let opts_strings = cli + .into_iter() + .map(|o| o.extract()) + .collect::>>()?; + + let opts = opts_strings + .iter() + .map(|s: &String| s.as_ptr() as *const i8) + .collect::>(); + let opts_lens = opts_strings + .iter() + .map(|s| s.as_bytes().len()) + .collect::>(); + + let mut out = ptr::null_mut(); + unsafe { + match parity_config_from_cli(opts.as_ptr(), opts_lens.as_ptr(), cli_len, &mut out) { + 0 => Ok(ConfigHandle { inner: out }), + _ => Err(ValueError::py_err("failed to create config object")), + } + } +} + +/// Create a running Parity instance given a config +#[pyfunction] +unsafe fn build( + _py: Python<'_>, + config: &mut ConfigHandle, + logger_mode: &str, + logger_file: &str, +) -> PyResult { + let mut params = ParityParams { + configuration: config.inner, + ..mem::zeroed() + }; + + parity_set_logger( + logger_mode.as_ptr(), + logger_mode.as_bytes().len(), + logger_file.as_ptr(), + logger_file.as_bytes().len(), + &mut params.logger, + ); + + let mut out = ptr::null_mut(); + let ret = match parity_start(¶ms, &mut out) { + 0 => Ok(ParityHandle { inner: out }), + _ => Err(RuntimeError::py_err("failed to start Parity")), + }; + + // Ensure we don't double-free config + config.inner = ptr::null_mut(); + ret +} + +/// Perform a RPC query against a running Parity instance, invoking callback on completion +#[pyfunction] +fn rpc_query( + _py: Python<'_>, + parity: &ParityHandle, + rpc: &str, + timeout_ms: u64, + callback: PyObject, +) -> PyResult<()> { + if parity.inner == ptr::null_mut() { + return Err(ValueError::py_err("Parity execution completed")); + } + + let client = unsafe { &*(parity.inner as *const RunningClient) }; + let callback = Arc::new(PythonCallback::new(callback)); + parity_rpc_worker(client, rpc, callback, timeout_ms); + Ok(()) +} + +/// Subscribe to a websocket event, invoking callback when event received +#[pyfunction] +fn subscribe_ws( + _py: Python<'_>, + parity: &ParityHandle, + rpc: &str, + callback: PyObject, +) -> PyResult { + if parity.inner == ptr::null_mut() { + return Err(ValueError::py_err("Parity execution completed")); + } + + let client = unsafe { &*(parity.inner as *const RunningClient) }; + let callback = Arc::new(PythonCallback::new(callback)); + + Ok(SubscriptionHandle { + inner: parity_ws_worker(client, rpc, callback), + }) +} + +/// Python extension module exposing Parity functionality +#[pymodule] +fn _parity(_py: Python<'_>, m: &PyModule) -> PyResult<()> { + m.add_wrapped(wrap_pyfunction!(config_from_cli))?; + m.add_wrapped(wrap_pyfunction!(build))?; + m.add_wrapped(wrap_pyfunction!(rpc_query))?; + m.add_wrapped(wrap_pyfunction!(subscribe_ws))?; + + Ok(()) +} From 61fa9cf3a15d917e0b80244a423706c092cfaf2c Mon Sep 17 00:00:00 2001 From: Maxwell Koo Date: Sat, 2 Mar 2019 16:57:05 -0700 Subject: [PATCH 2/3] Update Cargo.lock --- Cargo.lock | 190 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 157 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71061696dee..a7ad1ac9bd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -504,6 +504,15 @@ dependencies = [ "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ctor" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ctrlc" version = "1.1.1" @@ -543,7 +552,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -566,7 +575,7 @@ dependencies = [ "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lunarity-lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", @@ -605,7 +614,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -654,8 +663,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -909,7 +918,7 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1324,8 +1333,8 @@ name = "failure_derive" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1476,6 +1485,16 @@ dependencies = [ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ghost" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "globset" version = "0.4.2" @@ -1485,7 +1504,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1520,7 +1539,7 @@ dependencies = [ "pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1724,6 +1743,26 @@ name = "interleaved-ordered" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "inventory" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ctor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ghost 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "inventory-impl 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "inventory-impl" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "iovec" version = "0.1.2" @@ -1841,8 +1880,8 @@ name = "jsonrpc-derive" version = "10.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2107,6 +2146,24 @@ dependencies = [ name = "macros" version = "0.1.0" +[[package]] +name = "mashup" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "mashup-impl 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mashup-impl" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "matches" version = "0.1.8" @@ -2337,7 +2394,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2443,6 +2500,7 @@ dependencies = [ "jni 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", "parity-ethereum 2.5.0", + "pyo3 0.6.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2529,7 +2587,7 @@ dependencies = [ "parity-whisper 0.1.0", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "registrar 0.0.1", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3054,9 +3112,22 @@ dependencies = [ "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro-hack" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-hack-impl" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" -version = "0.4.20" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3101,6 +3172,42 @@ dependencies = [ "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pyo3" +version = "0.6.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "inventory 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "mashup 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pyo3cls 0.6.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pyo3-derive-backend" +version = "0.6.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pyo3cls" +version = "0.6.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "pyo3-derive-backend 0.6.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.2" @@ -3113,10 +3220,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.8" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3272,7 +3379,7 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3370,8 +3477,8 @@ dependencies = [ name = "rlp_derive" version = "0.1.0" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3506,8 +3613,8 @@ name = "serde_derive" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3614,6 +3721,11 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "spin" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -3651,8 +3763,8 @@ name = "syn" version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3669,8 +3781,8 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4232,7 +4344,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4246,9 +4358,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "validator 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4515,6 +4627,7 @@ dependencies = [ "checksum csv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d54f6b0fd69128a2894b1a3e57af5849a0963c1cc77b165d30b896e40296452" "checksum csv-core 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4dd8e6d86f7ba48b4276ef1317edc8cc36167546d8972feb4a2b5fec0b374105" "checksum ct-logs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1b4660f8b07a560a88c02d76286edb9f0d5d64e495d2b0f233186155aa51be1f" +"checksum ctor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9a43db2bba5cafdc6aa068c892a518e477ee0df3705e53ec70247a9ff93546d5" "checksum ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)" = "" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" @@ -4550,6 +4663,7 @@ dependencies = [ "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" +"checksum ghost 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5297b71943dc9fea26a3241b178c140ee215798b7f79f7773fd61683e25bca74" "checksum globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4743617a7464bbda3c8aec8558ff2f9429047e025771037df561d383337ff865" "checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" @@ -4572,6 +4686,8 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" +"checksum inventory 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21df85981fe094480bc2267723d3dc0fd1ae0d1f136affc659b7398be615d922" +"checksum inventory-impl 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8a877ae8bce77402d5e9ed870730939e097aad827b2a932b361958fa9d6e75aa" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)" = "70783119ac90828aaba91eae39db32c6c1b8838deea3637e5238efa0130801ab" "checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc" @@ -4610,6 +4726,8 @@ dependencies = [ "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" "checksum lunarity-lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a1670671f305792567116d4660e6e5bd785d6fa973e817c3445c0a7a54cecb6" +"checksum mashup 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f2d82b34c7fb11bb41719465c060589e291d505ca4735ea30016a91f6fc79c3b" +"checksum mashup-impl 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "aa607bfb674b4efb310512527d64266b065de3f894fc52f84efcbf7eaa5965fb" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" @@ -4673,13 +4791,18 @@ dependencies = [ "checksum primal-check 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8e65f96c0a171f887198c274392c99a116ef65aa7f53f3b6d4902f493965c2d1" "checksum primal-estimate 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "56ea4531dde757b56906493c8604641da14607bf9cdaa80fb9c9cabd2429f8d5" "checksum primal-sieve 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "da2d6ed369bb4b0273aeeb43f07c105c0117717cbae827b20719438eb2eb798c" -"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" +"checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" +"checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" +"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" "checksum protobuf 1.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "52fbc45bf6709565e44ef31847eb7407b3c3c80af811ee884a04da071dcca12b" "checksum pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8361e81576d2e02643b04950e487ec172b687180da65c731c03cf336784e6c07" "checksum pwasm-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e9135bed7b452e20dbb395a2d519abaf0c46d60e7ecc02daeeab447d29bada1" +"checksum pyo3 0.6.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "00d5a665157dd1b4b2a6cf851f29fad4e78b6525c028edeebb036368136dabb3" +"checksum pyo3-derive-backend 0.6.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "de5efe5e5c51c44eab434a517f9258c5e67ad8bd95f6cc9e92b71b80d5003349" +"checksum pyo3cls 0.6.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "152892bb1ada7e21a5c37d6bbd345067222e777513e417c883e80775e1473d39" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" +"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" @@ -4696,7 +4819,7 @@ dependencies = [ "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" +"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" @@ -4737,6 +4860,7 @@ dependencies = [ "checksum slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9776d6b986f77b35c6cf846c11ad986ff128fe0b2b63a3628e3755e8d3102d" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" "checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7" +"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" From a0719ccbd89ec447e454f781d7b067a30891f542 Mon Sep 17 00:00:00 2001 From: Maxwell Koo Date: Wed, 13 Mar 2019 00:28:31 -0600 Subject: [PATCH 3/3] Address review comments --- parity-clib/examples/python/example.py | 2 +- parity-clib/python/.gitignore | 1 - parity-clib/python/parity/__init__.py | 6 +++--- parity-clib/src/python.rs | 16 +++++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/parity-clib/examples/python/example.py b/parity-clib/examples/python/example.py index 7f41e02c68e..4d61b19a69a 100644 --- a/parity-clib/examples/python/example.py +++ b/parity-clib/examples/python/example.py @@ -24,7 +24,7 @@ # Run a RPC query and print the results query = "{\"method\":\"parity_versionInfo\",\"params\":[],\"id\":1,\"jsonrpc\":\"2.0\"}" -print('version info:', p.rpc_query(query)) +print('version info:', p.rpc_query_sync(query)) # Subscribe to a websocket event ws_query = "{\"method\":\"parity_subscribe\",\"params\":[\"parity_netPeers\"],\"id\":1,\"jsonrpc\":\"2.0\"}" diff --git a/parity-clib/python/.gitignore b/parity-clib/python/.gitignore index c7e0a9e8d6a..d158b1ef4b4 100644 --- a/parity-clib/python/.gitignore +++ b/parity-clib/python/.gitignore @@ -1,4 +1,3 @@ -*.so *.egg-info/ __pycache__/ build/ diff --git a/parity-clib/python/parity/__init__.py b/parity-clib/python/parity/__init__.py index e09d6c3052e..b43c47a6708 100644 --- a/parity-clib/python/parity/__init__.py +++ b/parity-clib/python/parity/__init__.py @@ -81,7 +81,7 @@ def __init__(self, options, logger_mode='', logger_file=''): config = _parity.config_from_cli(options) self.handle = _parity.build(config, logger_mode, logger_file) - def rpc_query_cb(self, query, cb, timeout_ms=1000): + def rpc_query_async(self, query, cb, timeout_ms=1000): """Perform a RPC query, return immediately, cb will be invoked with the result asynchronously :param query: Query to perform @@ -90,7 +90,7 @@ def rpc_query_cb(self, query, cb, timeout_ms=1000): """ _parity.rpc_query(self.handle, query, timeout_ms, cb) - def rpc_query(self, query, timeout_ms=1000): + def rpc_query_sync(self, query, timeout_ms=1000): """Perform a RPC query and return the result synchronously :param query: Query to perform @@ -98,7 +98,7 @@ def rpc_query(self, query, timeout_ms=1000): :return: Result of the rpc call """ cb = _CallbackGenerator() - self.rpc_query_cb(query, cb, timeout_ms) + self.rpc_query_async(query, cb, timeout_ms) return next(cb) def subscribe_ws_cb(self, query, cb): diff --git a/parity-clib/src/python.rs b/parity-clib/src/python.rs index d4fdcb47094..ec19f64df78 100644 --- a/parity-clib/src/python.rs +++ b/parity-clib/src/python.rs @@ -21,7 +21,9 @@ use std::sync::Arc; use parity_ethereum::RunningClient; use pyo3::exceptions::{RuntimeError, ValueError}; -use pyo3::prelude::*; +use pyo3::prelude::{ + pyclass, pyfunction, pymethods, pymodule, ObjectProtocol, PyModule, PyObject, PyResult, Python, +}; use pyo3::types::PyList; use { parity_config_destroy, parity_config_from_cli, parity_destroy, parity_rpc_worker, @@ -177,8 +179,10 @@ fn rpc_query( timeout_ms: u64, callback: PyObject, ) -> PyResult<()> { - if parity.inner == ptr::null_mut() { - return Err(ValueError::py_err("Parity execution completed")); + if parity.inner.is_null() { + return Err(ValueError::py_err( + "Attempt to query RPC when ParityClient is not running", + )); } let client = unsafe { &*(parity.inner as *const RunningClient) }; @@ -195,8 +199,10 @@ fn subscribe_ws( rpc: &str, callback: PyObject, ) -> PyResult { - if parity.inner == ptr::null_mut() { - return Err(ValueError::py_err("Parity execution completed")); + if parity.inner.is_null() { + return Err(ValueError::py_err( + "Attempt to subscribe to WebSocket when ParityClient is not running", + )); } let client = unsafe { &*(parity.inner as *const RunningClient) };