revm_database/states/
transition_state.rsuse super::TransitionAccount;
use primitives::{hash_map::Entry, Address, HashMap};
use std::vec::Vec;
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub struct TransitionState {
pub transitions: HashMap<Address, TransitionAccount>,
}
impl TransitionState {
pub fn single(address: Address, transition: TransitionAccount) -> Self {
let mut transitions = HashMap::default();
transitions.insert(address, transition);
TransitionState { transitions }
}
pub fn take(&mut self) -> TransitionState {
core::mem::take(self)
}
pub fn add_transitions(&mut self, transitions: Vec<(Address, TransitionAccount)>) {
for (address, account) in transitions {
match self.transitions.entry(address) {
Entry::Occupied(entry) => {
let entry = entry.into_mut();
entry.update(account);
}
Entry::Vacant(entry) => {
entry.insert(account);
}
}
}
}
}