Skip to main content

diff_slashings

Function diff_slashings 

Source
pub fn diff_slashings(
    base_slot: u64,
    target_slot: u64,
    base_buffer: &[u64],
    target_buffer: &[u64],
    slots_per_epoch: u64,
) -> SlashingsDiff
Expand description

Computes a sparse delta between two slashing buffers.

The encoder compares the epochs traversed while advancing from base_slot to target_slot and records only entries whose values have changed.

The returned delta contains pairs of (ring_index, value) representing the updated slashing totals.

§Arguments

  • base_slot - Starting slot.
  • target_slot - Ending slot.
  • base_buffer - Base slashing ring buffer.
  • target_buffer - Target slashing ring buffer.
  • slots_per_epoch - Number of slots in a consensus epoch.

§Complexity

O(number of traversed epochs)

§Panics

Panics if target_slot < base_slot.