mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 19:32:55 +00:00
superstruct the AttesterSlashing (#5636)
* `superstruct` Attester Fork Variants * Push a little further * Deal with Encode / Decode of AttesterSlashing * not so sure about this.. * Stop Encode/Decode Bounds from Propagating Out * Tons of Changes.. * More Conversions to AttestationRef * Add AsReference trait (#15) * Add AsReference trait * Fix some snafus * Got it Compiling! :D * Got Tests Building * Get beacon chain tests compiling --------- Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
use crate::max_cover::MaxCover;
|
||||
use state_processing::per_block_processing::get_slashable_indices_modular;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use types::{AttesterSlashing, BeaconState, EthSpec};
|
||||
use types::{AttesterSlashing, AttesterSlashingRef, BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AttesterSlashingMaxCover<'a, E: EthSpec> {
|
||||
slashing: &'a AttesterSlashing<E>,
|
||||
slashing: AttesterSlashingRef<'a, E>,
|
||||
effective_balances: HashMap<u64, u64>,
|
||||
}
|
||||
|
||||
impl<'a, E: EthSpec> AttesterSlashingMaxCover<'a, E> {
|
||||
pub fn new(
|
||||
slashing: &'a AttesterSlashing<E>,
|
||||
slashing: AttesterSlashingRef<'a, E>,
|
||||
proposer_slashing_indices: &HashSet<u64>,
|
||||
state: &BeaconState<E>,
|
||||
) -> Option<Self> {
|
||||
@@ -39,16 +39,16 @@ impl<'a, E: EthSpec> AttesterSlashingMaxCover<'a, E> {
|
||||
impl<'a, E: EthSpec> MaxCover for AttesterSlashingMaxCover<'a, E> {
|
||||
/// The result type, of which we would eventually like a collection of maximal quality.
|
||||
type Object = AttesterSlashing<E>;
|
||||
type Intermediate = AttesterSlashing<E>;
|
||||
type Intermediate = AttesterSlashingRef<'a, E>;
|
||||
/// The type used to represent sets.
|
||||
type Set = HashMap<u64, u64>;
|
||||
|
||||
fn intermediate(&self) -> &AttesterSlashing<E> {
|
||||
self.slashing
|
||||
fn intermediate(&self) -> &AttesterSlashingRef<'a, E> {
|
||||
&self.slashing
|
||||
}
|
||||
|
||||
fn convert_to_object(slashing: &AttesterSlashing<E>) -> AttesterSlashing<E> {
|
||||
slashing.clone()
|
||||
fn convert_to_object(slashing: &AttesterSlashingRef<'a, E>) -> AttesterSlashing<E> {
|
||||
slashing.clone_as_attester_slashing()
|
||||
}
|
||||
|
||||
/// Get the set of elements covered.
|
||||
@@ -58,7 +58,7 @@ impl<'a, E: EthSpec> MaxCover for AttesterSlashingMaxCover<'a, E> {
|
||||
/// Update the set of items covered, for the inclusion of some object in the solution.
|
||||
fn update_covering_set(
|
||||
&mut self,
|
||||
_best_slashing: &AttesterSlashing<E>,
|
||||
_best_slashing: &AttesterSlashingRef<'a, E>,
|
||||
covered_validator_indices: &HashMap<u64, u64>,
|
||||
) {
|
||||
self.effective_balances
|
||||
|
||||
Reference in New Issue
Block a user