mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-30 03:03:45 +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::ser::{Serialize, Serializer};
|
||||
use ssz::{Decode, Encode};
|
||||
use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use tree_hash::TreeHash;
|
||||
|
||||
@@ -84,6 +85,12 @@ impl<Pub, Sig> PartialEq for GenericSignatureBytes<Pub, Sig> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Pub, Sig> Hash for GenericSignatureBytes<Pub, Sig> {
|
||||
fn hash<H: Hasher>(&self, hasher: &mut H) {
|
||||
self.bytes.hash(hasher);
|
||||
}
|
||||
}
|
||||
|
||||
/// Serializes the `GenericSignature` in compressed form, storing the bytes in the newly created `Self`.
|
||||
impl<Pub, Sig> From<GenericSignature<Pub, Sig>> for GenericSignatureBytes<Pub, Sig>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user