Skip to content

Commit

Permalink
Add comment block for insert_shreds_handle_duplicate in blockstore.rs (
Browse files Browse the repository at this point in the history
  • Loading branch information
yhchiang-sol authored Dec 22, 2021
1 parent ddde356 commit 3155a04
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,57 @@ impl Blockstore {
recovered_data_shreds
}

/// The main helper function that performs the shred insertion logic
/// and updates corresponding meta-data.
///
/// This function updates the following column families:
/// - [`cf::DeadSlots`]: mark a shred as "dead" if its meta-data indicates
/// there is no need to replay this shred. Specifically when both the
/// following conditions satisfy,
/// - We get a new shred N marked as the last shred in the slot S,
/// but N.index() is less than the current slot_meta.received
/// for slot S.
/// - The slot is not currently full
/// It means there's an alternate version of this slot. See
/// `check_insert_data_shred` for more details.
/// - [`cf::ShredData`]: stores data shreds (in check_insert_data_shreds).
/// - [`cf::ShredCode`]: stores coding shreds (in check_insert_coding_shreds).
/// - [`cf::SlotMeta`]: the SlotMeta of the input `shreds` and their related
/// shreds are updated. Specifically:
/// - `handle_chaining()` updates `cf::SlotMeta` in two ways. First, it
/// updates the in-memory slot_meta_working_set, which will later be
/// persisted in commit_slot_meta_working_set(). Second, for the newly
/// chained slots (updated inside handle_chaining_for_slot()), it will
/// directly persist their slot-meta into `cf::SlotMeta`.
/// - In `commit_slot_meta_working_set()`, persists everything stored
/// in the in-memory structure slot_meta_working_set, which is updated
/// by both `check_insert_data_shred()` and `handle_chaining()`.
/// - [`cf::Orphans`]: add or remove the ID of a slot to `cf::Orphans`
/// if it becomes / is no longer an orphan slot in `handle_chaining()`.
/// - [`cf::ErasureMeta`]: the associated ErasureMeta of the coding and data
/// shreds inside `shreds` will be updated and committed to
/// `cf::ErasureMeta`.
/// - [`cf::Index`]: stores (slot id, index to the index_working_set_entry)
/// pair to the `cf::Index` column family for each index_working_set_entry
/// which insert did occur in this function call.
///
/// Arguments:
/// - `shreds`: the shreds to be inserted.
/// - `is_repaired`: a boolean vector aligned with `shreds` where each
/// boolean indicates whether the corresponding shred is repaired or not.
/// - `leader_schedule`: the leader schedule
/// - `is_trusted`: whether the shreds come from a trusted source. If this
/// is set to true, then the function will skip the shred duplication and
/// integrity checks.
/// - `retransmit_sender`: the sender for transmitting any recovered
/// data shreds.
/// - `handle_duplicate`: a function for handling shreds that have the same slot
/// and index.
/// - `metrics`: the metric for reporting detailed stats
///
/// On success, the function returns an Ok result with a vector of
/// `CompletedDataSetInfo` and a vector of its corresponding index in the
/// input `shreds` vector.
pub fn insert_shreds_handle_duplicate<F>(
&self,
shreds: Vec<Shred>,
Expand Down

0 comments on commit 3155a04

Please sign in to comment.