Add TreeHash derives for cache objects.
This allows us to avoid a verbose manual impl for BeaconState
This commit is contained in:
parent
7660cbd419
commit
b37cf3a269
@ -1,5 +1,7 @@
|
|||||||
use super::{AttestationDuty, BeaconState, CrosslinkCommittees, Error};
|
use super::{AttestationDuty, BeaconState, CrosslinkCommittees, Error};
|
||||||
|
use crate::test_utils::TestRandom;
|
||||||
use crate::{ChainSpec, Epoch};
|
use crate::{ChainSpec, Epoch};
|
||||||
|
use rand::RngCore;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
|
||||||
@ -67,3 +69,14 @@ impl EpochCache {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: RngCore> TestRandom<T> for [EpochCache; 3] {
|
||||||
|
/// Test random should generate an empty cache.
|
||||||
|
fn random_for_test(rng: &mut T) -> Self {
|
||||||
|
[
|
||||||
|
EpochCache::default(),
|
||||||
|
EpochCache::default(),
|
||||||
|
EpochCache::default(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
use crate::test_utils::TestRandom;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
use rand::RngCore;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@ -36,3 +38,10 @@ impl PubkeyCache {
|
|||||||
self.map.get(pubkey).cloned()
|
self.map.get(pubkey).cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: RngCore> TestRandom<T> for PubkeyCache {
|
||||||
|
/// Test random should generate an empty cache.
|
||||||
|
fn random_for_test(rng: &mut T) -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user