jsonrpc eth_getCode method

This commit is contained in:
debris
2016-02-08 10:58:08 +01:00
parent 4116bdd8fd
commit 3adfebdc20
7 changed files with 127 additions and 2 deletions

View File

@@ -86,6 +86,9 @@ pub trait BlockChainClient : Sync + Send {
/// Get block total difficulty.
fn block_total_difficulty(&self, hash: &H256) -> Option<U256>;
/// Get address code.
fn code(&self, address: &Address) -> Option<Bytes>;
/// Get raw block header data by block number.
fn block_header_at(&self, n: BlockNumber) -> Option<Bytes>;
@@ -357,6 +360,10 @@ impl BlockChainClient for Client {
self.chain.read().unwrap().block_details(hash).map(|d| d.total_difficulty)
}
fn code(&self, address: &Address) -> Option<Bytes> {
self.state().code(address)
}
fn block_header_at(&self, n: BlockNumber) -> Option<Bytes> {
self.chain.read().unwrap().block_hash(n).and_then(|h| self.block_header(&h))
}