mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Fix all compile errors from new Slot/Epoch types
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use crate::{DutiesReader, DutiesReaderError};
|
||||
use std::collections::HashMap;
|
||||
use types::{Epoch, Slot};
|
||||
|
||||
pub struct EpochMap {
|
||||
epoch_length: u64,
|
||||
pub map: HashMap<u64, u64>,
|
||||
pub map: HashMap<Epoch, Slot>,
|
||||
}
|
||||
|
||||
impl EpochMap {
|
||||
@@ -16,8 +17,8 @@ impl EpochMap {
|
||||
}
|
||||
|
||||
impl DutiesReader for EpochMap {
|
||||
fn is_block_production_slot(&self, slot: u64) -> Result<bool, DutiesReaderError> {
|
||||
let epoch = slot / self.epoch_length;
|
||||
fn is_block_production_slot(&self, slot: Slot) -> Result<bool, DutiesReaderError> {
|
||||
let epoch = slot.epoch(self.epoch_length);
|
||||
match self.map.get(&epoch) {
|
||||
Some(s) if *s == slot => Ok(true),
|
||||
Some(s) if *s != slot => Ok(false),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::traits::{BeaconNode, BeaconNodeError, PublishOutcome};
|
||||
use std::sync::RwLock;
|
||||
use types::{BeaconBlock, PublicKey, Signature};
|
||||
use types::{BeaconBlock, PublicKey, Signature, Slot};
|
||||
|
||||
type NonceResult = Result<u64, BeaconNodeError>;
|
||||
type ProduceResult = Result<Option<BeaconBlock>, BeaconNodeError>;
|
||||
@@ -12,7 +12,7 @@ pub struct SimulatedBeaconNode {
|
||||
pub nonce_input: RwLock<Option<PublicKey>>,
|
||||
pub nonce_result: RwLock<Option<NonceResult>>,
|
||||
|
||||
pub produce_input: RwLock<Option<(u64, Signature)>>,
|
||||
pub produce_input: RwLock<Option<(Slot, Signature)>>,
|
||||
pub produce_result: RwLock<Option<ProduceResult>>,
|
||||
|
||||
pub publish_input: RwLock<Option<BeaconBlock>>,
|
||||
@@ -46,7 +46,7 @@ impl BeaconNode for SimulatedBeaconNode {
|
||||
}
|
||||
|
||||
/// Returns the value specified by the `set_next_produce_result`.
|
||||
fn produce_beacon_block(&self, slot: u64, randao_reveal: &Signature) -> ProduceResult {
|
||||
fn produce_beacon_block(&self, slot: Slot, randao_reveal: &Signature) -> ProduceResult {
|
||||
*self.produce_input.write().unwrap() = Some((slot, randao_reveal.clone()));
|
||||
match *self.produce_result.read().unwrap() {
|
||||
Some(ref r) => r.clone(),
|
||||
|
||||
Reference in New Issue
Block a user