* Add RepairWeight
Co-authored-by: Carl <carl@solana.com>
(cherry picked from commit 3f6042d8b3
)
Co-authored-by: carllin <wumu727@gmail.com>
This commit is contained in:
@ -349,6 +349,12 @@ impl HeaviestSubtreeForkChoice {
|
||||
self.add_votes(&new_votes, epoch_stakes, epoch_schedule);
|
||||
}
|
||||
|
||||
pub fn stake_voted_at(&self, slot: Slot) -> Option<u64> {
|
||||
self.fork_infos
|
||||
.get(&slot)
|
||||
.map(|fork_info| fork_info.stake_voted_at)
|
||||
}
|
||||
|
||||
fn propagate_new_leaf(&mut self, slot: Slot, parent: Slot) {
|
||||
let parent_best_slot = self
|
||||
.best_slot(parent)
|
||||
@ -526,13 +532,6 @@ impl HeaviestSubtreeForkChoice {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn stake_voted_at(&self, slot: Slot) -> Option<u64> {
|
||||
self.fork_infos
|
||||
.get(&slot)
|
||||
.map(|fork_info| fork_info.stake_voted_at)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn set_stake_voted_at(&mut self, slot: Slot, stake_voted_at: u64) {
|
||||
self.fork_infos.get_mut(&slot).unwrap().stake_voted_at = stake_voted_at;
|
||||
|
@ -41,6 +41,7 @@ pub mod progress_map;
|
||||
pub mod pubkey_references;
|
||||
pub mod repair_response;
|
||||
pub mod repair_service;
|
||||
pub mod repair_weight;
|
||||
pub mod repair_weighted_traversal;
|
||||
pub mod replay_stage;
|
||||
mod result;
|
||||
|
@ -73,6 +73,8 @@ pub struct RepairStats {
|
||||
pub shred: RepairStatsGroup,
|
||||
pub highest_shred: RepairStatsGroup,
|
||||
pub orphan: RepairStatsGroup,
|
||||
pub get_best_orphans_us: u64,
|
||||
pub get_best_shreds_us: u64,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
@ -179,6 +181,7 @@ impl RepairService {
|
||||
let mut repair_timing = RepairTiming::default();
|
||||
let mut last_stats = Instant::now();
|
||||
let duplicate_slot_repair_statuses = HashMap::new();
|
||||
|
||||
Self::initialize_epoch_slots(
|
||||
blockstore,
|
||||
&cluster_info,
|
||||
|
1239
core/src/repair_weight.rs
Normal file
1239
core/src/repair_weight.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,7 @@ use std::{
|
||||
pub const MAX_ORPHAN_REPAIR_RESPONSES: usize = 10;
|
||||
pub const DEFAULT_NONCE: u32 = 42;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||
pub enum RepairType {
|
||||
Orphan(Slot),
|
||||
HighestShred(Slot, u64),
|
||||
|
@ -346,7 +346,8 @@ impl Blockstore {
|
||||
let mut walk = TreeWalk::from(forks);
|
||||
while let Some(visit) = walk.get() {
|
||||
let slot = visit.node().data;
|
||||
if self.meta(slot).unwrap().is_some() {
|
||||
if self.meta(slot).unwrap().is_some() && self.orphan(slot).unwrap().is_none() {
|
||||
// If slot exists and is not an orphan, then skip it
|
||||
walk.forward();
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user