2020-10-19 13:19:24 -07:00
|
|
|
use crate::{
|
2020-01-10 16:57:31 -07:00
|
|
|
account::Account,
|
2020-01-22 17:54:06 -08:00
|
|
|
account_utils::StateMut,
|
2020-03-05 07:40:26 -07:00
|
|
|
fee_calculator::FeeCalculator,
|
2020-01-10 16:57:31 -07:00
|
|
|
hash::Hash,
|
2020-09-29 21:34:07 -06:00
|
|
|
nonce::{state::Versions, State},
|
2019-12-07 12:54:10 -07:00
|
|
|
};
|
|
|
|
|
2020-01-22 16:31:39 -07:00
|
|
|
pub fn verify_nonce_account(acc: &Account, hash: &Hash) -> bool {
|
2020-03-03 19:39:09 -07:00
|
|
|
match StateMut::<Versions>::state(acc).map(|v| v.convert_to_current()) {
|
2020-03-04 09:51:48 -07:00
|
|
|
Ok(State::Initialized(ref data)) => *hash == data.blockhash,
|
2019-12-07 12:54:10 -07:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 07:40:26 -07:00
|
|
|
pub fn fee_calculator_of(account: &Account) -> Option<FeeCalculator> {
|
|
|
|
let state = StateMut::<Versions>::state(account)
|
|
|
|
.ok()?
|
|
|
|
.convert_to_current();
|
|
|
|
match state {
|
|
|
|
State::Initialized(data) => Some(data.fee_calculator),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|