uncle method mock
This commit is contained in:
parent
47ca84041b
commit
9b241faf01
@ -223,6 +223,11 @@ impl<'a> BlockView<'a> {
|
|||||||
pub fn uncle_hashes(&self) -> Vec<H256> {
|
pub fn uncle_hashes(&self) -> Vec<H256> {
|
||||||
self.rlp.at(2).iter().map(|rlp| rlp.as_raw().sha3()).collect()
|
self.rlp.at(2).iter().map(|rlp| rlp.as_raw().sha3()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return nth uncle.
|
||||||
|
pub fn uncle_at(&self, index: usize) -> Option<Header> {
|
||||||
|
self.rlp.at(2).iter().nth(index).map(|rlp| rlp.as_val())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Hashable for BlockView<'a> {
|
impl<'a> Hashable for BlockView<'a> {
|
||||||
|
@ -125,6 +125,11 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
|
|||||||
None => Ok(Value::Null)
|
None => Ok(Value::Null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn uncle(&self, _block: BlockId, _index: usize) -> Result<Value, Error> {
|
||||||
|
// TODO: implement!
|
||||||
|
Ok(Value::Null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
||||||
@ -285,6 +290,16 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
.and_then(|(number, index)| self.transaction(TransactionId::Location(number.into(), index.value())))
|
.and_then(|(number, index)| self.transaction(TransactionId::Location(number.into(), index.value())))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn uncle_by_block_hash_and_index(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
from_params::<(H256, Index)>(params)
|
||||||
|
.and_then(|(hash, index)| self.uncle(BlockId::Hash(hash), index.value()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn uncle_by_block_number_and_index(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
from_params::<(BlockNumber, Index)>(params)
|
||||||
|
.and_then(|(number, index)| self.uncle(number.into(), index.value()))
|
||||||
|
}
|
||||||
|
|
||||||
fn compilers(&self, params: Params) -> Result<Value, Error> {
|
fn compilers(&self, params: Params) -> Result<Value, Error> {
|
||||||
match params {
|
match params {
|
||||||
Params::None => to_value(&vec![] as &Vec<String>),
|
Params::None => to_value(&vec![] as &Vec<String>),
|
||||||
|
@ -102,7 +102,10 @@ pub trait Eth: Sized + Send + Sync + 'static {
|
|||||||
fn transaction_receipt(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
fn transaction_receipt(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
|
|
||||||
/// Returns an uncles at given block and index.
|
/// Returns an uncles at given block and index.
|
||||||
fn uncle_at(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
fn uncle_by_block_hash_and_index(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
|
|
||||||
|
/// Returns an uncles at given block and index.
|
||||||
|
fn uncle_by_block_number_and_index(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
|
|
||||||
/// Returns available compilers.
|
/// Returns available compilers.
|
||||||
fn compilers(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
fn compilers(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||||
@ -158,8 +161,8 @@ pub trait Eth: Sized + Send + Sync + 'static {
|
|||||||
delegate.add_method("eth_getTransactionByBlockHashAndIndex", Eth::transaction_by_block_hash_and_index);
|
delegate.add_method("eth_getTransactionByBlockHashAndIndex", Eth::transaction_by_block_hash_and_index);
|
||||||
delegate.add_method("eth_getTransactionByBlockNumberAndIndex", Eth::transaction_by_block_number_and_index);
|
delegate.add_method("eth_getTransactionByBlockNumberAndIndex", Eth::transaction_by_block_number_and_index);
|
||||||
delegate.add_method("eth_getTransactionReceipt", Eth::transaction_receipt);
|
delegate.add_method("eth_getTransactionReceipt", Eth::transaction_receipt);
|
||||||
delegate.add_method("eth_getUncleByBlockHashAndIndex", Eth::uncle_at);
|
delegate.add_method("eth_getUncleByBlockHashAndIndex", Eth::uncle_by_block_hash_and_index);
|
||||||
delegate.add_method("eth_getUncleByBlockNumberAndIndex", Eth::uncle_at);
|
delegate.add_method("eth_getUncleByBlockNumberAndIndex", Eth::uncle_by_block_number_and_index);
|
||||||
delegate.add_method("eth_getCompilers", Eth::compilers);
|
delegate.add_method("eth_getCompilers", Eth::compilers);
|
||||||
delegate.add_method("eth_compileLLL", Eth::compile_lll);
|
delegate.add_method("eth_compileLLL", Eth::compile_lll);
|
||||||
delegate.add_method("eth_compileSolidity", Eth::compile_solidity);
|
delegate.add_method("eth_compileSolidity", Eth::compile_solidity);
|
||||||
|
Loading…
Reference in New Issue
Block a user