changed BlockPosition -> Location

This commit is contained in:
debris 2016-02-10 15:15:28 +01:00
parent dc8fa4ebfd
commit 5347d4fe43
2 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ pub enum TransactionId {
Hash(H256),
/// Block id and transaction index within this block.
/// Querying by block position is always faster.
BlockPosition(BlockId, usize)
Location(BlockId, usize)
}
/// Represents a tree route between `from` block and `to` block:
@ -132,11 +132,11 @@ pub trait BlockProvider {
fn transaction(&self, id: TransactionId) -> Option<LocalizedTransaction> {
match id {
TransactionId::Hash(ref hash) => self.transaction_address(hash),
TransactionId::BlockPosition(BlockId::Hash(hash), index) => Some(TransactionAddress {
TransactionId::Location(BlockId::Hash(hash), index) => Some(TransactionAddress {
block_hash: hash,
index: index
}),
TransactionId::BlockPosition(BlockId::Number(number), index) => self.block_hash(number).map(|hash| TransactionAddress {
TransactionId::Location(BlockId::Number(number), index) => self.block_hash(number).map(|hash| TransactionAddress {
block_hash: hash,
index: index
})

View File

@ -166,7 +166,7 @@ impl Eth for EthClient {
fn transaction_by_block_hash_and_index(&self, params: Params) -> Result<Value, Error> {
from_params::<(H256, Index)>(params)
.and_then(|(hash, index)| match self.client.transaction(TransactionId::BlockPosition(BlockId::Hash(hash), index.value())) {
.and_then(|(hash, index)| match self.client.transaction(TransactionId::Location(BlockId::Hash(hash), index.value())) {
Some(t) => to_value(&Transaction::from(t)),
None => Ok(Value::Null)
})