mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-24 00:08:27 +00:00
Compare commits
3 Commits
v7.0.0-bet
...
v7.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
796e3567c8 | ||
|
|
56bb6c1968 | ||
|
|
8f2194eb2c |
@@ -1,6 +1,7 @@
|
|||||||
use crate::errors::BeaconChainError;
|
use crate::errors::BeaconChainError;
|
||||||
use crate::{BeaconChainTypes, BeaconStore};
|
use crate::{BeaconChainTypes, BeaconStore};
|
||||||
use bls::PUBLIC_KEY_UNCOMPRESSED_BYTES_LEN;
|
use bls::PUBLIC_KEY_UNCOMPRESSED_BYTES_LEN;
|
||||||
|
use slog::{debug, Logger};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use ssz::{Decode, Encode};
|
use ssz::{Decode, Encode};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
@@ -18,6 +19,7 @@ use types::{BeaconState, FixedBytesExtended, Hash256, PublicKey, PublicKeyBytes}
|
|||||||
/// keys in compressed form and they are needed in decompressed form for signature verification.
|
/// keys in compressed form and they are needed in decompressed form for signature verification.
|
||||||
/// Decompression is expensive when many keys are involved.
|
/// Decompression is expensive when many keys are involved.
|
||||||
pub struct ValidatorPubkeyCache<T: BeaconChainTypes> {
|
pub struct ValidatorPubkeyCache<T: BeaconChainTypes> {
|
||||||
|
log: Logger,
|
||||||
pubkeys: Vec<PublicKey>,
|
pubkeys: Vec<PublicKey>,
|
||||||
indices: HashMap<PublicKeyBytes, usize>,
|
indices: HashMap<PublicKeyBytes, usize>,
|
||||||
pubkey_bytes: Vec<PublicKeyBytes>,
|
pubkey_bytes: Vec<PublicKeyBytes>,
|
||||||
@@ -33,6 +35,7 @@ impl<T: BeaconChainTypes> ValidatorPubkeyCache<T> {
|
|||||||
store: BeaconStore<T>,
|
store: BeaconStore<T>,
|
||||||
) -> Result<Self, BeaconChainError> {
|
) -> Result<Self, BeaconChainError> {
|
||||||
let mut cache = Self {
|
let mut cache = Self {
|
||||||
|
log: store.log.clone(),
|
||||||
pubkeys: vec![],
|
pubkeys: vec![],
|
||||||
indices: HashMap::new(),
|
indices: HashMap::new(),
|
||||||
pubkey_bytes: vec![],
|
pubkey_bytes: vec![],
|
||||||
@@ -64,7 +67,14 @@ impl<T: BeaconChainTypes> ValidatorPubkeyCache<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let indices_len = indices.len();
|
||||||
|
debug!(
|
||||||
|
store.log,
|
||||||
|
"Loaded pubkey cache from store. Indices: {}", indices_len
|
||||||
|
);
|
||||||
|
|
||||||
Ok(ValidatorPubkeyCache {
|
Ok(ValidatorPubkeyCache {
|
||||||
|
log: store.log.clone(),
|
||||||
pubkeys,
|
pubkeys,
|
||||||
indices,
|
indices,
|
||||||
pubkey_bytes,
|
pubkey_bytes,
|
||||||
@@ -105,6 +115,12 @@ impl<T: BeaconChainTypes> ValidatorPubkeyCache<T> {
|
|||||||
self.pubkeys.reserve(validator_keys.len());
|
self.pubkeys.reserve(validator_keys.len());
|
||||||
self.indices.reserve(validator_keys.len());
|
self.indices.reserve(validator_keys.len());
|
||||||
|
|
||||||
|
let count = validator_keys.len();
|
||||||
|
debug!(
|
||||||
|
self.log,
|
||||||
|
"Importing new pubkeys to the pubkey cache. count: {}", count
|
||||||
|
);
|
||||||
|
|
||||||
let mut store_ops = Vec::with_capacity(validator_keys.len());
|
let mut store_ops = Vec::with_capacity(validator_keys.len());
|
||||||
for pubkey_bytes in validator_keys {
|
for pubkey_bytes in validator_keys {
|
||||||
let i = self.pubkeys.len();
|
let i = self.pubkeys.len();
|
||||||
|
|||||||
Reference in New Issue
Block a user