mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Metrics for sync aggregate fullness (#2439)
## Issue Addressed NA ## Proposed Changes Adds a metric to see how many set bits are in the sync aggregate for each beacon block being imported. ## Additional Info NA
This commit is contained in:
@@ -45,6 +45,16 @@ pub struct BeaconBlockBody<T: EthSpec> {
|
||||
pub sync_aggregate: SyncAggregate<T>,
|
||||
}
|
||||
|
||||
impl<'a, T: EthSpec> BeaconBlockBodyRef<'a, T> {
|
||||
/// Access the sync aggregate from the block's body, if one exists.
|
||||
pub fn sync_aggregate(self) -> Option<&'a SyncAggregate<T>> {
|
||||
match self {
|
||||
BeaconBlockBodyRef::Base(_) => None,
|
||||
BeaconBlockBodyRef::Altair(inner) => Some(&inner.sync_aggregate),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod base {
|
||||
|
||||
@@ -33,4 +33,9 @@ impl<T: EthSpec> SyncAggregate<T> {
|
||||
sync_committee_signature: AggregateSignature::empty(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns how many bits are `true` in `self.sync_committee_bits`.
|
||||
pub fn num_set_bits(&self) -> usize {
|
||||
self.sync_committee_bits.num_set_bits()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user