RPC errors & logs (#1845)
* Refactoring errors in RPC * Updating jsonrpc-core * Fixing code_at * Avoid mentioning obvious segments in proof [ci:skip]
This commit is contained in:
@@ -784,8 +784,8 @@ impl BlockChainClient for Client {
|
||||
Self::block_hash(&self.chain, id)
|
||||
}
|
||||
|
||||
fn code(&self, address: &Address) -> Option<Bytes> {
|
||||
self.state().code(address)
|
||||
fn code(&self, address: &Address, id: BlockID) -> Option<Option<Bytes>> {
|
||||
self.state_at(id).map(|s| s.code(address))
|
||||
}
|
||||
|
||||
fn balance(&self, address: &Address, id: BlockID) -> Option<U256> {
|
||||
|
||||
@@ -319,8 +319,11 @@ impl BlockChainClient for TestBlockChainClient {
|
||||
self.nonce(address, BlockID::Latest).unwrap()
|
||||
}
|
||||
|
||||
fn code(&self, address: &Address) -> Option<Bytes> {
|
||||
self.code.read().get(address).cloned()
|
||||
fn code(&self, address: &Address, id: BlockID) -> Option<Option<Bytes>> {
|
||||
match id {
|
||||
BlockID::Latest => Some(self.code.read().get(address).cloned()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn balance(&self, address: &Address, id: BlockID) -> Option<U256> {
|
||||
|
||||
@@ -81,8 +81,14 @@ pub trait BlockChainClient : Sync + Send {
|
||||
/// Get block hash.
|
||||
fn block_hash(&self, id: BlockID) -> Option<H256>;
|
||||
|
||||
/// Get address code.
|
||||
fn code(&self, address: &Address) -> Option<Bytes>;
|
||||
/// Get address code at given block's state.
|
||||
fn code(&self, address: &Address, id: BlockID) -> Option<Option<Bytes>>;
|
||||
|
||||
/// Get address code at the latest block's state.
|
||||
fn latest_code(&self, address: &Address) -> Option<Bytes> {
|
||||
self.code(address, BlockID::Latest)
|
||||
.expect("code will return Some if given BlockID::Latest; qed")
|
||||
}
|
||||
|
||||
/// Get address balance at the given block's state.
|
||||
///
|
||||
|
||||
@@ -528,7 +528,7 @@ impl MinerService for Miner {
|
||||
|
||||
fn code(&self, chain: &MiningBlockChainClient, address: &Address) -> Option<Bytes> {
|
||||
let sealing_work = self.sealing_work.lock();
|
||||
sealing_work.queue.peek_last_ref().map_or_else(|| chain.code(address), |b| b.block().fields().state.code(address))
|
||||
sealing_work.queue.peek_last_ref().map_or_else(|| chain.latest_code(address), |b| b.block().fields().state.code(address))
|
||||
}
|
||||
|
||||
fn set_author(&self, author: Address) {
|
||||
|
||||
Reference in New Issue
Block a user