rename x_latest to latest_x in BlockChainClient

This commit is contained in:
Robert Habermeier 2016-05-26 22:17:55 +02:00
parent 30eee76767
commit 3f89362630
4 changed files with 17 additions and 17 deletions

View File

@ -70,7 +70,7 @@ pub trait BlockChainClient : Sync + Send {
fn nonce(&self, address: &Address, id: BlockID) -> Option<U256>;
/// Get address nonce at the latest block's state.
fn nonce_latest(&self, address: &Address) -> U256 {
fn latest_nonce(&self, address: &Address) -> U256 {
self.nonce(address, BlockID::Latest)
.expect("nonce will return Some when given BlockID::Latest. nonce was given BlockID::Latest. \
Therefore nonce has returned Some; qed")
@ -89,7 +89,7 @@ pub trait BlockChainClient : Sync + Send {
fn balance(&self, address: &Address, id: BlockID) -> Option<U256>;
/// Get address balance at the latest block's state.
fn balance_latest(&self, address: &Address) -> U256 {
fn latest_balance(&self, address: &Address) -> U256 {
self.balance(address, BlockID::Latest)
.expect("balance will return Some if given BlockID::Latest. balance was given BlockID::Latest \
Therefore balance has returned Some; qed")
@ -102,7 +102,7 @@ pub trait BlockChainClient : Sync + Send {
fn storage_at(&self, address: &Address, position: &H256, id: BlockID) -> Option<H256>;
/// Get value of the storage at given position at the latest block's state.
fn storage_at_latest(&self, address: &Address, position: &H256) -> H256 {
fn latest_storage_at(&self, address: &Address, position: &H256) -> H256 {
self.storage_at(address, position, BlockID::Latest)
.expect("storage_at will return Some if given BlockID::Latest. storage_at was given BlockID::Latest. \
Therefore storage_at has returned Some; qed")

View File

@ -167,8 +167,8 @@ impl Miner {
};
let mut queue = self.transaction_queue.lock().unwrap();
let fetch_account = |a: &Address| AccountDetails {
nonce: chain.nonce_latest(a),
balance: chain.balance_latest(a),
nonce: chain.latest_nonce(a),
balance: chain.latest_balance(a),
};
for hash in invalid_transactions.into_iter() {
queue.remove_invalid(&hash, &fetch_account);
@ -291,7 +291,7 @@ impl MinerService for Miner {
fn balance(&self, chain: &BlockChainClient, address: &Address) -> U256 {
let sealing_work = self.sealing_work.lock().unwrap();
sealing_work.peek_last_ref().map_or_else(
|| chain.balance_latest(address),
|| chain.latest_balance(address),
|b| b.block().fields().state.balance(address)
)
}
@ -299,14 +299,14 @@ impl MinerService for Miner {
fn storage_at(&self, chain: &BlockChainClient, address: &Address, position: &H256) -> H256 {
let sealing_work = self.sealing_work.lock().unwrap();
sealing_work.peek_last_ref().map_or_else(
|| chain.storage_at_latest(address, position),
|| chain.latest_storage_at(address, position),
|b| b.block().fields().state.storage_at(address, position)
)
}
fn nonce(&self, chain: &BlockChainClient, address: &Address) -> U256 {
let sealing_work = self.sealing_work.lock().unwrap();
sealing_work.peek_last_ref().map_or_else(|| chain.nonce_latest(address), |b| b.block().fields().state.nonce(address))
sealing_work.peek_last_ref().map_or_else(|| chain.latest_nonce(address), |b| b.block().fields().state.nonce(address))
}
fn code(&self, chain: &BlockChainClient, address: &Address) -> Option<Bytes> {
@ -551,8 +551,8 @@ impl MinerService for Miner {
let _sender = tx.sender();
}
let _ = self.import_transactions(txs, |a| AccountDetails {
nonce: chain.nonce_latest(a),
balance: chain.balance_latest(a),
nonce: chain.latest_nonce(a),
balance: chain.latest_balance(a),
});
});
}
@ -572,7 +572,7 @@ impl MinerService for Miner {
})
.collect::<HashSet<Address>>();
for sender in to_remove.into_iter() {
transaction_queue.remove_all(sender, chain.nonce_latest(&sender));
transaction_queue.remove_all(sender, chain.latest_nonce(&sender));
}
});
}

View File

@ -164,7 +164,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
.or_else(|| miner
.last_nonce(&request.from)
.map(|nonce| nonce + U256::one()))
.unwrap_or_else(|| client.nonce_latest(&request.from)),
.unwrap_or_else(|| client.latest_nonce(&request.from)),
action: request.to.map_or(Action::Create, Action::Call),
gas: request.gas.unwrap_or_else(|| miner.sensible_gas_limit()),
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
@ -181,7 +181,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
let miner = take_weak!(self.miner);
let from = request.from.unwrap_or(Address::zero());
Ok(EthTransaction {
nonce: request.nonce.unwrap_or_else(|| client.nonce_latest(&from)),
nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)),
action: request.to.map_or(Action::Create, Action::Call),
gas: request.gas.unwrap_or(U256::from(50_000_000)),
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
@ -199,8 +199,8 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
miner.import_own_transaction(client.deref(), signed_transaction, |a: &Address| {
AccountDetails {
nonce: client.nonce_latest(&a),
balance: client.balance_latest(&a),
nonce: client.latest_nonce(&a),
balance: client.latest_balance(&a),
}
})
};

View File

@ -900,8 +900,8 @@ impl ChainSync {
}
let chain = io.chain();
let fetch_account = |a: &Address| AccountDetails {
nonce: chain.nonce_latest(a),
balance: chain.balance_latest(a),
nonce: chain.latest_nonce(a),
balance: chain.latest_balance(a),
};
let _ = self.miner.import_transactions(transactions, fetch_account);
Ok(())