mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 03:44:30 +00:00
Lazy hashing for SignedBeaconBlock in sync (#2916)
## Proposed Changes Allocate less memory in sync by hashing the `SignedBeaconBlock`s in a batch directly, rather than going via SSZ bytes. Credit to @paulhauner for finding this source of temporary allocations.
This commit is contained in:
@@ -9,6 +9,7 @@ use serde::de::{Deserialize, Deserializer};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use ssz::{Decode, Encode};
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use tree_hash::TreeHash;
|
||||
|
||||
@@ -264,6 +265,18 @@ where
|
||||
impl_tree_hash!(SIGNATURE_BYTES_LEN);
|
||||
}
|
||||
|
||||
/// Hashes the `self.serialize()` bytes.
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
impl<Pub, AggPub, Sig, AggSig> Hash for GenericAggregateSignature<Pub, AggPub, Sig, AggSig>
|
||||
where
|
||||
Sig: TSignature<Pub>,
|
||||
AggSig: TAggregateSignature<Pub, AggPub, Sig>,
|
||||
{
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.serialize().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl<Pub, AggPub, Sig, AggSig> fmt::Display for GenericAggregateSignature<Pub, AggPub, Sig, AggSig>
|
||||
where
|
||||
Sig: TSignature<Pub>,
|
||||
|
||||
Reference in New Issue
Block a user