Make empty params array optional for parity_subscribe.
This commit is contained in:
parent
9994133446
commit
df910277a2
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -1017,7 +1017,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-core"
|
name = "jsonrpc-core"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1029,7 +1029,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-http-server"
|
name = "jsonrpc-http-server"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)",
|
"hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)",
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
@ -1042,7 +1042,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-ipc-server"
|
name = "jsonrpc-ipc-server"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bytes 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
@ -1055,7 +1055,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-macros"
|
name = "jsonrpc-macros"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
"jsonrpc-pubsub 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-pubsub 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
@ -1065,7 +1065,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-minihttp-server"
|
name = "jsonrpc-minihttp-server"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
"jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
@ -1079,7 +1079,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-pubsub"
|
name = "jsonrpc-pubsub"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1089,7 +1089,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-server-utils"
|
name = "jsonrpc-server-utils"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
@ -1101,7 +1101,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-tcp-server"
|
name = "jsonrpc-tcp-server"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bytes 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
@ -1115,7 +1115,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-ws-server"
|
name = "jsonrpc-ws-server"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d"
|
source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
"jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
"jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||||
|
@ -162,7 +162,7 @@ impl LightFetch {
|
|||||||
|
|
||||||
let (sync, on_demand, client) = (self.sync.clone(), self.on_demand.clone(), self.client.clone());
|
let (sync, on_demand, client) = (self.sync.clone(), self.on_demand.clone(), self.client.clone());
|
||||||
let req: CallRequestHelper = req.into();
|
let req: CallRequestHelper = req.into();
|
||||||
let id = num.0.into();
|
let id = num.unwrap_or_default().into();
|
||||||
|
|
||||||
let from = req.from.unwrap_or(Address::zero());
|
let from = req.from.unwrap_or(Address::zero());
|
||||||
let nonce_fut = match req.nonce {
|
let nonce_fut = match req.nonce {
|
||||||
|
@ -361,7 +361,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||||
let address = address.into();
|
let address = address.into();
|
||||||
|
|
||||||
let res = match num.0.clone() {
|
let res = match num.unwrap_or_default() {
|
||||||
BlockNumber::Pending => {
|
BlockNumber::Pending => {
|
||||||
match self.miner.balance(&*self.client, &address) {
|
match self.miner.balance(&*self.client, &address) {
|
||||||
Some(balance) => Ok(balance.into()),
|
Some(balance) => Ok(balance.into()),
|
||||||
@ -384,7 +384,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
let address: Address = RpcH160::into(address);
|
let address: Address = RpcH160::into(address);
|
||||||
let position: U256 = RpcU256::into(pos);
|
let position: U256 = RpcU256::into(pos);
|
||||||
|
|
||||||
let res = match num.0.clone() {
|
let res = match num.unwrap_or_default() {
|
||||||
BlockNumber::Pending => {
|
BlockNumber::Pending => {
|
||||||
match self.miner.storage_at(&*self.client, &address, &H256::from(position)) {
|
match self.miner.storage_at(&*self.client, &address, &H256::from(position)) {
|
||||||
Some(s) => Ok(s.into()),
|
Some(s) => Ok(s.into()),
|
||||||
@ -406,7 +406,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||||
let address: Address = RpcH160::into(address);
|
let address: Address = RpcH160::into(address);
|
||||||
|
|
||||||
let res = match num.0.clone() {
|
let res = match num.unwrap_or_default() {
|
||||||
BlockNumber::Pending if self.options.pending_nonce_from_queue => {
|
BlockNumber::Pending if self.options.pending_nonce_from_queue => {
|
||||||
let nonce = self.miner.last_nonce(&address)
|
let nonce = self.miner.last_nonce(&address)
|
||||||
.map(|n| n + 1.into())
|
.map(|n| n + 1.into())
|
||||||
@ -468,7 +468,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
fn code_at(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
fn code_at(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||||
let address: Address = RpcH160::into(address);
|
let address: Address = RpcH160::into(address);
|
||||||
|
|
||||||
let res = match num.0.clone() {
|
let res = match num.unwrap_or_default() {
|
||||||
BlockNumber::Pending => {
|
BlockNumber::Pending => {
|
||||||
match self.miner.code(&*self.client, &address) {
|
match self.miner.code(&*self.client, &address) {
|
||||||
Some(code) => Ok(code.map_or_else(Bytes::default, Bytes::new)),
|
Some(code) => Ok(code.map_or_else(Bytes::default, Bytes::new)),
|
||||||
@ -553,7 +553,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn work(&self, no_new_work_timeout: Trailing<u64>) -> Result<Work, Error> {
|
fn work(&self, no_new_work_timeout: Trailing<u64>) -> Result<Work, Error> {
|
||||||
let no_new_work_timeout = no_new_work_timeout.0;
|
let no_new_work_timeout = no_new_work_timeout.unwrap_or_default();
|
||||||
|
|
||||||
// check if we're still syncing and return empty strings in that case
|
// check if we're still syncing and return empty strings in that case
|
||||||
{
|
{
|
||||||
@ -638,7 +638,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
Err(e) => return future::err(e).boxed(),
|
Err(e) => return future::err(e).boxed(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = match num.0 {
|
let result = match num.unwrap_or_default() {
|
||||||
BlockNumber::Pending => self.miner.call(&*self.client, &signed, Default::default()),
|
BlockNumber::Pending => self.miner.call(&*self.client, &signed, Default::default()),
|
||||||
num => self.client.call(&signed, num.into(), Default::default()),
|
num => self.client.call(&signed, num.into(), Default::default()),
|
||||||
};
|
};
|
||||||
@ -655,7 +655,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
|||||||
Ok(signed) => signed,
|
Ok(signed) => signed,
|
||||||
Err(e) => return future::err(e).boxed(),
|
Err(e) => return future::err(e).boxed(),
|
||||||
};
|
};
|
||||||
future::done(self.client.estimate_gas(&signed, num.0.into())
|
future::done(self.client.estimate_gas(&signed, num.unwrap_or_default().into())
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
.map_err(errors::from_call_error)
|
.map_err(errors::from_call_error)
|
||||||
).boxed()
|
).boxed()
|
||||||
|
@ -136,8 +136,9 @@ impl<C: Send + Sync + 'static> EthPubSub for EthPubSubClient<C> {
|
|||||||
kind: pubsub::Kind,
|
kind: pubsub::Kind,
|
||||||
params: Trailing<pubsub::Params>,
|
params: Trailing<pubsub::Params>,
|
||||||
) {
|
) {
|
||||||
match (kind, params.0) {
|
let params: Option<pubsub::Params> = params.into();
|
||||||
(pubsub::Kind::NewHeads, pubsub::Params::None) => {
|
match (kind, params) {
|
||||||
|
(pubsub::Kind::NewHeads, None) => {
|
||||||
self.heads_subscribers.lock().push(subscriber)
|
self.heads_subscribers.lock().push(subscriber)
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -270,7 +270,7 @@ impl Eth for EthClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||||
self.fetcher().account(address.into(), num.0.into())
|
self.fetcher().account(address.into(), num.unwrap_or_default().into())
|
||||||
.map(|acc| acc.map_or(0.into(), |a| a.balance).into()).boxed()
|
.map(|acc| acc.map_or(0.into(), |a| a.balance).into()).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ impl Eth for EthClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||||
self.fetcher().account(address.into(), num.0.into())
|
self.fetcher().account(address.into(), num.unwrap_or_default().into())
|
||||||
.map(|acc| acc.map_or(0.into(), |a| a.nonce).into()).boxed()
|
.map(|acc| acc.map_or(0.into(), |a| a.nonce).into()).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ impl Parity for ParityClient {
|
|||||||
type Metadata = Metadata;
|
type Metadata = Metadata;
|
||||||
|
|
||||||
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error> {
|
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error> {
|
||||||
let dapp = dapp.0;
|
let dapp = dapp.unwrap_or_default();
|
||||||
|
|
||||||
let store = &self.accounts;
|
let store = &self.accounts;
|
||||||
let dapp_accounts = store
|
let dapp_accounts = store
|
||||||
@ -383,7 +383,7 @@ impl Parity for ParityClient {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.fetcher().header(number.0.into()).map(from_encoded).boxed()
|
self.fetcher().header(number.unwrap_or_default().into()).map(from_encoded).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ipfs_cid(&self, content: Bytes) -> Result<String, Error> {
|
fn ipfs_cid(&self, content: Bytes) -> Result<String, Error> {
|
||||||
|
@ -124,7 +124,7 @@ impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where
|
|||||||
type Metadata = Metadata;
|
type Metadata = Metadata;
|
||||||
|
|
||||||
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error> {
|
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error> {
|
||||||
let dapp = dapp.0;
|
let dapp = dapp.unwrap_or_default();
|
||||||
|
|
||||||
let store = self.account_provider()?;
|
let store = self.account_provider()?;
|
||||||
let dapp_accounts = store
|
let dapp_accounts = store
|
||||||
@ -272,13 +272,13 @@ impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where
|
|||||||
|
|
||||||
fn list_accounts(&self, count: u64, after: Option<H160>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error> {
|
fn list_accounts(&self, count: u64, after: Option<H160>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error> {
|
||||||
Ok(self.client
|
Ok(self.client
|
||||||
.list_accounts(block_number.0.into(), after.map(Into::into).as_ref(), count)
|
.list_accounts(block_number.unwrap_or_default().into(), after.map(Into::into).as_ref(), count)
|
||||||
.map(|a| a.into_iter().map(Into::into).collect()))
|
.map(|a| a.into_iter().map(Into::into).collect()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_storage_keys(&self, address: H160, count: u64, after: Option<H256>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error> {
|
fn list_storage_keys(&self, address: H160, count: u64, after: Option<H256>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error> {
|
||||||
Ok(self.client
|
Ok(self.client
|
||||||
.list_storage(block_number.0.into(), &address.into(), after.map(Into::into).as_ref(), count)
|
.list_storage(block_number.unwrap_or_default().into(), &address.into(), after.map(Into::into).as_ref(), count)
|
||||||
.map(|a| a.into_iter().map(Into::into).collect()))
|
.map(|a| a.into_iter().map(Into::into).collect()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +389,7 @@ impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where
|
|||||||
fn block_header(&self, number: Trailing<BlockNumber>) -> BoxFuture<RichHeader, Error> {
|
fn block_header(&self, number: Trailing<BlockNumber>) -> BoxFuture<RichHeader, Error> {
|
||||||
const EXTRA_INFO_PROOF: &'static str = "Object exists in in blockchain (fetched earlier), extra_info is always available if object exists; qed";
|
const EXTRA_INFO_PROOF: &'static str = "Object exists in in blockchain (fetched earlier), extra_info is always available if object exists; qed";
|
||||||
|
|
||||||
let id: BlockId = number.0.into();
|
let id: BlockId = number.unwrap_or_default().into();
|
||||||
let encoded = match self.client.block_header(id.clone()) {
|
let encoded = match self.client.block_header(id.clone()) {
|
||||||
Some(encoded) => encoded,
|
Some(encoded) => encoded,
|
||||||
None => return future::err(errors::unknown_block()).boxed(),
|
None => return future::err(errors::unknown_block()).boxed(),
|
||||||
|
@ -22,6 +22,7 @@ use util::RwLock;
|
|||||||
|
|
||||||
use futures::{self, BoxFuture, Future, Stream, Sink};
|
use futures::{self, BoxFuture, Future, Stream, Sink};
|
||||||
use jsonrpc_core::{self as core, Error, MetaIoHandler};
|
use jsonrpc_core::{self as core, Error, MetaIoHandler};
|
||||||
|
use jsonrpc_macros::Trailing;
|
||||||
use jsonrpc_macros::pubsub::Subscriber;
|
use jsonrpc_macros::pubsub::Subscriber;
|
||||||
use jsonrpc_pubsub::SubscriptionId;
|
use jsonrpc_pubsub::SubscriptionId;
|
||||||
use tokio_timer;
|
use tokio_timer;
|
||||||
@ -64,7 +65,8 @@ impl<S: core::Middleware<Metadata>> PubSubClient<S> {
|
|||||||
impl<S: core::Middleware<Metadata>> PubSub for PubSubClient<S> {
|
impl<S: core::Middleware<Metadata>> PubSub for PubSubClient<S> {
|
||||||
type Metadata = Metadata;
|
type Metadata = Metadata;
|
||||||
|
|
||||||
fn parity_subscribe(&self, mut meta: Metadata, subscriber: Subscriber<core::Value>, method: String, params: core::Params) {
|
fn parity_subscribe(&self, mut meta: Metadata, subscriber: Subscriber<core::Value>, method: String, params: Trailing<core::Params>) {
|
||||||
|
let params = params.unwrap_or(core::Params::Array(vec![]));
|
||||||
// Make sure to get rid of PubSub session otherwise it will never be dropped.
|
// Make sure to get rid of PubSub session otherwise it will never be dropped.
|
||||||
meta.session = None;
|
meta.session = None;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ impl<C, M> Traces for TracesClient<C, M> where C: MiningBlockChainClient + 'stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn call(&self, request: CallRequest, flags: Vec<String>, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
fn call(&self, request: CallRequest, flags: Vec<String>, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||||
let block = block.0;
|
let block = block.unwrap_or_default();
|
||||||
|
|
||||||
let request = CallRequest::into(request);
|
let request = CallRequest::into(request);
|
||||||
let signed = fake_sign::sign_call(&self.client, &self.miner, request)?;
|
let signed = fake_sign::sign_call(&self.client, &self.miner, request)?;
|
||||||
@ -91,7 +91,7 @@ impl<C, M> Traces for TracesClient<C, M> where C: MiningBlockChainClient + 'stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn raw_transaction(&self, raw_transaction: Bytes, flags: Vec<String>, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
fn raw_transaction(&self, raw_transaction: Bytes, flags: Vec<String>, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||||
let block = block.0;
|
let block = block.unwrap_or_default();
|
||||||
|
|
||||||
let tx = UntrustedRlp::new(&raw_transaction.into_vec()).as_val().map_err(|e| errors::invalid_params("Transaction is not valid RLP", e))?;
|
let tx = UntrustedRlp::new(&raw_transaction.into_vec()).as_val().map_err(|e| errors::invalid_params("Transaction is not valid RLP", e))?;
|
||||||
let signed = SignedTransaction::new(tx).map_err(errors::from_transaction_error)?;
|
let signed = SignedTransaction::new(tx).map_err(errors::from_transaction_error)?;
|
||||||
|
@ -52,7 +52,7 @@ fn should_subscribe_to_a_method() {
|
|||||||
metadata.session = Some(Arc::new(Session::new(sender)));
|
metadata.session = Some(Arc::new(Session::new(sender)));
|
||||||
|
|
||||||
// Subscribe
|
// Subscribe
|
||||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_subscribe", "params": ["hello", []], "id": 1}"#;
|
let request = r#"{"jsonrpc": "2.0", "method": "parity_subscribe", "params": ["hello"], "id": 1}"#;
|
||||||
let response = r#"{"jsonrpc":"2.0","result":1,"id":1}"#;
|
let response = r#"{"jsonrpc":"2.0","result":1,"id":1}"#;
|
||||||
assert_eq!(io.handle_request_sync(request, metadata.clone()), Some(response.to_owned()));
|
assert_eq!(io.handle_request_sync(request, metadata.clone()), Some(response.to_owned()));
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
use jsonrpc_core::{Error, Value, Params};
|
use jsonrpc_core::{Error, Value, Params};
|
||||||
use jsonrpc_pubsub::SubscriptionId;
|
use jsonrpc_pubsub::SubscriptionId;
|
||||||
|
use jsonrpc_macros::Trailing;
|
||||||
use jsonrpc_macros::pubsub::Subscriber;
|
use jsonrpc_macros::pubsub::Subscriber;
|
||||||
use futures::BoxFuture;
|
use futures::BoxFuture;
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ build_rpc_trait! {
|
|||||||
#[pubsub(name = "parity_subscription")] {
|
#[pubsub(name = "parity_subscription")] {
|
||||||
/// Subscribe to changes of any RPC method in Parity.
|
/// Subscribe to changes of any RPC method in Parity.
|
||||||
#[rpc(name = "parity_subscribe")]
|
#[rpc(name = "parity_subscribe")]
|
||||||
fn parity_subscribe(&self, Self::Metadata, Subscriber<Value>, String, Params);
|
fn parity_subscribe(&self, Self::Metadata, Subscriber<Value>, String, Trailing<Params>);
|
||||||
|
|
||||||
/// Unsubscribe from existing Parity subscription.
|
/// Unsubscribe from existing Parity subscription.
|
||||||
#[rpc(name = "parity_unsubscribe")]
|
#[rpc(name = "parity_unsubscribe")]
|
||||||
|
Loading…
Reference in New Issue
Block a user