mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 19:34:37 +00:00
Remove dupe info between ChainSpec and EthSpec
This commit is contained in:
@@ -48,6 +48,8 @@ pub struct BlockProducer<'a, B: BeaconNodeBlock, S: Signer> {
|
||||
pub beacon_node: Arc<B>,
|
||||
/// The signer to sign the block.
|
||||
pub signer: &'a S,
|
||||
/// Used for caclulating epoch.
|
||||
pub slots_per_epoch: u64,
|
||||
}
|
||||
|
||||
impl<'a, B: BeaconNodeBlock, S: Signer> BlockProducer<'a, B, S> {
|
||||
@@ -84,7 +86,7 @@ impl<'a, B: BeaconNodeBlock, S: Signer> BlockProducer<'a, B, S> {
|
||||
/// The slash-protection code is not yet implemented. There is zero protection against
|
||||
/// slashing.
|
||||
pub fn produce_block(&mut self) -> Result<ValidatorEvent, Error> {
|
||||
let epoch = self.slot.epoch(self.spec.slots_per_epoch);
|
||||
let epoch = self.slot.epoch(self.slots_per_epoch);
|
||||
|
||||
let message = epoch.tree_hash_root();
|
||||
let randao_reveal = match self.signer.sign_message(
|
||||
@@ -186,9 +188,9 @@ mod tests {
|
||||
let beacon_node = Arc::new(SimulatedBeaconNode::default());
|
||||
let signer = Arc::new(LocalSigner::new(Keypair::random()));
|
||||
|
||||
let mut epoch_map = EpochMap::new(spec.slots_per_epoch);
|
||||
let mut epoch_map = EpochMap::new(T::slots_per_epoch());
|
||||
let produce_slot = Slot::new(100);
|
||||
let produce_epoch = produce_slot.epoch(spec.slots_per_epoch);
|
||||
let produce_epoch = produce_slot.epoch(T::slots_per_epoch());
|
||||
epoch_map.map.insert(produce_epoch, produce_slot);
|
||||
let epoch_map = Arc::new(epoch_map);
|
||||
|
||||
@@ -233,7 +235,7 @@ mod tests {
|
||||
);
|
||||
|
||||
// In an epoch without known duties...
|
||||
let slot = (produce_epoch.as_u64() + 1) * spec.slots_per_epoch;
|
||||
let slot = (produce_epoch.as_u64() + 1) * T::slots_per_epoch();
|
||||
slot_clock.set_slot(slot);
|
||||
assert_eq!(
|
||||
block_proposer.poll(),
|
||||
|
||||
Reference in New Issue
Block a user