implement storage_at_id
This commit is contained in:
@@ -578,6 +578,13 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
|
||||
self.state().storage_at(address, position)
|
||||
}
|
||||
|
||||
fn storage_at_id(&self, address: &Address, position: &H256, id: BlockID) -> Option<H256> {
|
||||
match id {
|
||||
BlockID::Latest => Some(self.storage_at(address, position)),
|
||||
id => self.state_at_id(id).map(|s| s.storage_at(address, position)),
|
||||
}
|
||||
}
|
||||
|
||||
fn transaction(&self, id: TransactionID) -> Option<LocalizedTransaction> {
|
||||
self.transaction_address(id).and_then(|address| self.chain.transaction(&address))
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ pub trait BlockChainClient : Sync + Send {
|
||||
|
||||
/// Account balance at a specific block ID.
|
||||
///
|
||||
/// Must not fail if `id` is `BlockID::Latest`.
|
||||
/// Will fail if the block is not valid or the block's root hash has been
|
||||
/// pruned from the DB.
|
||||
fn balance_at_id(&self, address: &Address, id: BlockID) -> Option<U256> {
|
||||
@@ -89,9 +90,18 @@ pub trait BlockChainClient : Sync + Send {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get value of the storage at given position.
|
||||
/// Get value of the storage at given position from the latest state.
|
||||
fn storage_at(&self, address: &Address, position: &H256) -> H256;
|
||||
|
||||
/// Get value of the storage at given position form the latest state.
|
||||
fn storage_at_id(&self, address: &Address, position: &H256, id: BlockID) -> Option<H256> {
|
||||
if let BlockID::Latest = id {
|
||||
Some(self.storage_at(address, position))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Get transaction with given hash.
|
||||
fn transaction(&self, id: TransactionID) -> Option<LocalizedTransaction>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user