Peek transaction queue via RPC (#2270)
* Handle RLP to string UTF-8 decoding errors (#2217) * pending transactions
This commit is contained in:
parent
905f04dc9d
commit
0db1c0d336
@ -26,7 +26,7 @@ use ethcore::client::{MiningBlockChainClient};
|
|||||||
|
|
||||||
use jsonrpc_core::*;
|
use jsonrpc_core::*;
|
||||||
use v1::traits::Ethcore;
|
use v1::traits::Ethcore;
|
||||||
use v1::types::{Bytes, U256, Peers, H160};
|
use v1::types::{Bytes, U256, Peers, H160, Transaction};
|
||||||
use v1::helpers::{errors, SigningQueue, ConfirmationsQueue, NetworkSettings};
|
use v1::helpers::{errors, SigningQueue, ConfirmationsQueue, NetworkSettings};
|
||||||
use v1::helpers::params::expect_no_params;
|
use v1::helpers::params::expect_no_params;
|
||||||
|
|
||||||
@ -200,4 +200,11 @@ impl<C, M, S: ?Sized> Ethcore for EthcoreClient<C, M, S> where M: MinerService +
|
|||||||
Some(ref queue) => to_value(&queue.len()),
|
Some(ref queue) => to_value(&queue.len()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(request), Some(response.to_owned()));
|
assert_eq!(io.handle_request(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()));
|
||||||
|
}
|
||||||
|
@ -70,6 +70,9 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
|||||||
/// Returns the value of the registrar for this network.
|
/// Returns the value of the registrar for this network.
|
||||||
fn registry_address(&self, _: Params) -> Result<Value, Error>;
|
fn registry_address(&self, _: Params) -> Result<Value, Error>;
|
||||||
|
|
||||||
|
/// Returns all transactions in 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));
|
||||||
@ -90,6 +93,7 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
|||||||
delegate.add_method("ethcore_gasPriceStatistics", Ethcore::gas_price_statistics);
|
delegate.add_method("ethcore_gasPriceStatistics", Ethcore::gas_price_statistics);
|
||||||
delegate.add_method("ethcore_unsignedTransactionsCount", Ethcore::unsigned_transactions_count);
|
delegate.add_method("ethcore_unsignedTransactionsCount", Ethcore::unsigned_transactions_count);
|
||||||
delegate.add_method("ethcore_registryAddress", Ethcore::registry_address);
|
delegate.add_method("ethcore_registryAddress", Ethcore::registry_address);
|
||||||
|
delegate.add_method("ethcore_pendingTransactions", Ethcore::pending_transactions);
|
||||||
delegate
|
delegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user