use super::*;
pub type MaybeCaughtValue = Option<u64>;
pub type RemainingNodes = BTreeMap<Key, GasNode>;
pub type RemovedNodes = BTreeMap<Key, GasNode>;
pub(super) fn consume_node(
consuming: Key,
) -> Result<(MaybeCaughtValue, RemainingNodes, RemovedNodes), super::Error> {
let nodes_before_consume = gas_tree_node_clone();
Gas::consume(consuming).map(|maybe_output| {
let maybe_caught_value = maybe_output.map(|(imb, ..)| imb.peek());
let remaining_nodes = gas_tree_node_clone();
let mut removed_nodes = BTreeMap::new();
for (id, node) in nodes_before_consume {
if !remaining_nodes.contains_key(&id) {
removed_nodes.insert(id, node);
}
}
(maybe_caught_value, remaining_nodes, removed_nodes)
})
}