jsonrpc eth_getCode method
This commit is contained in:
@@ -23,7 +23,7 @@ use util::sha3::*;
|
||||
use ethcore::client::*;
|
||||
use ethcore::views::*;
|
||||
use v1::traits::{Eth, EthFilter};
|
||||
use v1::types::{Block, SyncStatus};
|
||||
use v1::types::{Block, BlockNumber, Bytes, SyncStatus};
|
||||
|
||||
/// Eth rpc implementation.
|
||||
pub struct EthClient {
|
||||
@@ -115,6 +115,14 @@ impl Eth for EthClient {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: do not ignore block number param
|
||||
fn code_at(&self, params: Params) -> Result<Value, Error> {
|
||||
match from_params::<(Address, BlockNumber)>(params) {
|
||||
Ok((address, _block_number)) => to_value(&Bytes::new(self.client.code(&address).unwrap_or_else(|| vec![]))),
|
||||
Err(err) => Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
fn block(&self, params: Params) -> Result<Value, Error> {
|
||||
match from_params::<(H256, bool)>(params) {
|
||||
Ok((hash, _include_txs)) => match (self.client.block_header(&hash), self.client.block_total_difficulty(&hash)) {
|
||||
|
||||
Reference in New Issue
Block a user