rename locktower to tower (#6120)
This commit is contained in:
@ -129,7 +129,7 @@ impl Vote {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LockTower {
|
||||
pub struct Tower {
|
||||
votes: VecDeque<Vote>,
|
||||
max_size: usize,
|
||||
fork_trunk: Fork,
|
||||
@ -139,7 +139,7 @@ pub struct LockTower {
|
||||
parasite: bool,
|
||||
}
|
||||
|
||||
impl LockTower {
|
||||
impl Tower {
|
||||
pub fn new(max_size: usize, converge_depth: usize, delay_count: usize) -> Self {
|
||||
Self {
|
||||
votes: VecDeque::new(),
|
||||
@ -365,7 +365,7 @@ fn test_push_vote() {
|
||||
let tree = HashMap::new();
|
||||
let bmap = HashMap::new();
|
||||
let b0 = Fork { id: 0, base: 0 };
|
||||
let mut tower = LockTower::new(32, 7, 0);
|
||||
let mut tower = Tower::new(32, 7, 0);
|
||||
let vote = Vote::new(b0.clone(), 0);
|
||||
assert!(tower.push_vote(vote, &tree, &bmap));
|
||||
assert_eq!(tower.votes.len(), 1);
|
||||
@ -415,10 +415,10 @@ fn test_push_vote() {
|
||||
assert_eq!(tower.votes[1].lockout, 16);
|
||||
}
|
||||
|
||||
fn create_towers(sz: usize, height: usize, delay_count: usize) -> Vec<LockTower> {
|
||||
fn create_towers(sz: usize, height: usize, delay_count: usize) -> Vec<Tower> {
|
||||
(0..sz)
|
||||
.into_iter()
|
||||
.map(|_| LockTower::new(32, height, delay_count))
|
||||
.map(|_| Tower::new(32, height, delay_count))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -438,10 +438,7 @@ fn calc_fork_depth(fork_tree: &HashMap<usize, Fork>, id: usize) -> usize {
|
||||
/// map of `fork id` to `tower count`
|
||||
/// This map contains the number of nodes that have the fork as an ancestor.
|
||||
/// The fork with the highest count that is the newest is the cluster "trunk".
|
||||
fn calc_fork_map(
|
||||
towers: &Vec<LockTower>,
|
||||
fork_tree: &HashMap<usize, Fork>,
|
||||
) -> HashMap<usize, usize> {
|
||||
fn calc_fork_map(towers: &Vec<Tower>, fork_tree: &HashMap<usize, Fork>) -> HashMap<usize, usize> {
|
||||
let mut lca_map: HashMap<usize, usize> = HashMap::new();
|
||||
for tower in towers {
|
||||
let mut start = tower.last_fork();
|
||||
@ -463,7 +460,7 @@ fn calc_newest_trunk(bmap: &HashMap<usize, usize>) -> (usize, usize) {
|
||||
data.last().map(|v| (*v.0, *v.1)).unwrap()
|
||||
}
|
||||
/// how common is the latest fork of all the nodes
|
||||
fn calc_tip_converged(towers: &Vec<LockTower>, bmap: &HashMap<usize, usize>) -> usize {
|
||||
fn calc_tip_converged(towers: &Vec<Tower>, bmap: &HashMap<usize, usize>) -> usize {
|
||||
let sum: usize = towers
|
||||
.iter()
|
||||
.map(|n| *bmap.get(&n.last_fork().id).unwrap_or(&0))
|
||||
|
Reference in New Issue
Block a user