From a04b1f981e0a67d4cae9b395513b63723b05f67a Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 1 Jul 2019 15:21:11 +1000 Subject: [PATCH] op_pool: remove SszPair --- eth2/operation_pool/src/persistence.rs | 40 ++------------------------ 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/eth2/operation_pool/src/persistence.rs b/eth2/operation_pool/src/persistence.rs index 992c14555..aa6df597c 100644 --- a/eth2/operation_pool/src/persistence.rs +++ b/eth2/operation_pool/src/persistence.rs @@ -1,7 +1,6 @@ use crate::attestation_id::AttestationId; use crate::OperationPool; use parking_lot::RwLock; -use ssz::{Decode, Encode}; use ssz_derive::{Decode, Encode}; use types::*; @@ -14,7 +13,7 @@ pub struct PersistedOperationPool { /// Mapping from attestation ID to attestation mappings. // We could save space by not storing the attestation ID, but it might // be difficult to make that roundtrip due to eager aggregation. - attestations: Vec>>, + attestations: Vec<(AttestationId, Vec)>, deposits: Vec, /// Attester slashings. attester_slashings: Vec, @@ -33,7 +32,7 @@ impl PersistedOperationPool { .attestations .read() .iter() - .map(|(att_id, att)| SszPair::new(att_id.clone(), att.clone())) + .map(|(att_id, att)| (att_id.clone(), att.clone())) .collect(); let deposits = operation_pool @@ -82,7 +81,7 @@ impl PersistedOperationPool { state: &BeaconState, spec: &ChainSpec, ) -> OperationPool { - let attestations = RwLock::new(self.attestations.into_iter().map(SszPair::into).collect()); + let attestations = RwLock::new(self.attestations.into_iter().collect()); let deposits = RwLock::new(self.deposits.into_iter().map(|d| (d.index, d)).collect()); let attester_slashings = RwLock::new( self.attester_slashings @@ -120,36 +119,3 @@ impl PersistedOperationPool { } } } - -/// Tuples for SSZ. -#[derive(Encode, Decode)] -struct SszPair { - x: X, - y: Y, -} - -impl SszPair { - fn new(x: X, y: Y) -> Self { - Self { x, y } - } -} - -impl From<(X, Y)> for SszPair -where - X: Encode + Decode, - Y: Encode + Decode, -{ - fn from((x, y): (X, Y)) -> Self { - Self { x, y } - } -} - -impl Into<(X, Y)> for SszPair -where - X: Encode + Decode, - Y: Encode + Decode, -{ - fn into(self) -> (X, Y) { - (self.x, self.y) - } -}