Peek transaction queue via RPC (#2270)
* Handle RLP to string UTF-8 decoding errors (#2217) * pending transactions Conflicts: rpc/src/v1/impls/ethcore.rs rpc/src/v1/traits/ethcore.rs
This commit is contained in:
parent
efaef85565
commit
3e474216ac
@ -30,7 +30,7 @@ use ethcore::client::{MiningBlockChainClient};
|
|||||||
|
|
||||||
use jsonrpc_core::*;
|
use jsonrpc_core::*;
|
||||||
use v1::traits::Ethcore;
|
use v1::traits::Ethcore;
|
||||||
use v1::types::{Bytes, U256, H160, H512, Peers};
|
use v1::types::{Bytes, U256, H160, H512, Peers, Transaction};
|
||||||
use v1::helpers::{errors, SigningQueue, SignerService, NetworkSettings};
|
use v1::helpers::{errors, SigningQueue, SignerService, NetworkSettings};
|
||||||
use v1::helpers::params::expect_no_params;
|
use v1::helpers::params::expect_no_params;
|
||||||
|
|
||||||
@ -226,4 +226,11 @@ impl<C, M, S: ?Sized> Ethcore for EthcoreClient<C, M, S> where M: MinerService +
|
|||||||
Ok(to_value(&Bytes::from(s)))
|
Ok(to_value(&Bytes::from(s)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pending_transactions(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
try!(self.active());
|
||||||
|
try!(expect_no_params(params));
|
||||||
|
|
||||||
|
to_value(&take_weak!(self.miner).all_transactions().into_iter().map(Into::into).collect::<Vec<Transaction>>())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,3 +286,18 @@ fn rpc_ethcore_unsigned_transactions_count_when_signer_disabled() {
|
|||||||
|
|
||||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rpc_ethcore_pending_transactions() {
|
||||||
|
let miner = miner_service();
|
||||||
|
let client = client_service();
|
||||||
|
let sync = sync_provider();
|
||||||
|
let net = network_service();
|
||||||
|
let io = IoHandler::new();
|
||||||
|
io.add_delegate(ethcore_client(&client, &miner, &sync, &net).to_delegate());
|
||||||
|
|
||||||
|
let request = r#"{"jsonrpc": "2.0", "method": "ethcore_pendingTransactions", "params":[], "id": 1}"#;
|
||||||
|
let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#;
|
||||||
|
|
||||||
|
assert_eq!(io.handle_request(request), Some(response.to_owned()));
|
||||||
|
}
|
||||||
|
@ -80,6 +80,9 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
|||||||
/// First parameter is the 512-byte destination public key, second is the message.
|
/// First parameter is the 512-byte destination public key, second is the message.
|
||||||
fn encrypt_message(&self, _: Params) -> Result<Value, Error>;
|
fn encrypt_message(&self, _: Params) -> Result<Value, Error>;
|
||||||
|
|
||||||
|
/// Returns all pending (current) transactions from transaction queue.
|
||||||
|
fn pending_transactions(&self, _: Params) -> Result<Value, Error>;
|
||||||
|
|
||||||
/// Should be used to convert object to io delegate.
|
/// Should be used to convert object to io delegate.
|
||||||
fn to_delegate(self) -> IoDelegate<Self> {
|
fn to_delegate(self) -> IoDelegate<Self> {
|
||||||
let mut delegate = IoDelegate::new(Arc::new(self));
|
let mut delegate = IoDelegate::new(Arc::new(self));
|
||||||
@ -103,7 +106,7 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
|||||||
delegate.add_method("ethcore_phraseToAddress", Ethcore::phrase_to_address);
|
delegate.add_method("ethcore_phraseToAddress", Ethcore::phrase_to_address);
|
||||||
delegate.add_method("ethcore_registryAddress", Ethcore::registry_address);
|
delegate.add_method("ethcore_registryAddress", Ethcore::registry_address);
|
||||||
delegate.add_method("ethcore_encryptMessage", Ethcore::encrypt_message);
|
delegate.add_method("ethcore_encryptMessage", Ethcore::encrypt_message);
|
||||||
|
delegate.add_method("ethcore_pendingTransactions", Ethcore::pending_transactions);
|
||||||
delegate
|
delegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user