crate::ix!();
pub fn compute_tx_hash_info(
index: &AnnouncementIndex,
computer: &PriorityComputer) -> HashMap<u256,TxHashInfo> {
let mut ret = HashMap::<u256,TxHashInfo>::default();
for ann in index.get_by_txhash() {
let info: &mut TxHashInfo = ret.get_mut(&ann.txhash).unwrap();
info.candidate_delayed += match ann.get_state() == State::CANDIDATE_DELAYED { true => 1, false => 0 };
info.candidate_ready += match ann.get_state() == State::CANDIDATE_READY { true => 1, false => 0 };
info.candidate_best += match ann.get_state() == State::CANDIDATE_BEST { true => 1, false => 0 };
info.requested += match ann.get_state() == State::REQUESTED { true => 1, false => 0 };
if ann.get_state() == State::CANDIDATE_BEST {
info.priority_candidate_best = computer.invoke_announcement(&ann);
}
if ann.get_state() == State::CANDIDATE_READY {
info.priority_best_candidate_ready = max(
info.priority_best_candidate_ready,
computer.invoke_announcement(&ann)
);
}
info.peers.push(ann.peer);
}
ret
}