mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Fix clippy lints
This commit is contained in:
@@ -211,9 +211,8 @@ impl BeaconChainHarness {
|
||||
|
||||
// Ensure the validators slot clock is accurate.
|
||||
self.validators[proposer].set_slot(present_slot);
|
||||
let block = self.validators[proposer].produce_block().unwrap();
|
||||
|
||||
block
|
||||
self.validators[proposer].produce_block().unwrap()
|
||||
}
|
||||
|
||||
/// Advances the chain with a BeaconBlock and attestations from all validators.
|
||||
@@ -245,7 +244,7 @@ impl BeaconChainHarness {
|
||||
.for_each(|(i, attestation)| {
|
||||
self.beacon_chain
|
||||
.process_attestation(attestation.clone())
|
||||
.expect(&format!("Attestation {} invalid: {:?}", i, attestation));
|
||||
.unwrap_or_else(|_| panic!("Attestation {} invalid: {:?}", i, attestation));
|
||||
});
|
||||
|
||||
debug!("Attestations processed.");
|
||||
|
||||
@@ -52,6 +52,7 @@ impl StateCheck {
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics with an error message if any test fails.
|
||||
#[allow(clippy::cyclomatic_complexity)]
|
||||
pub fn assert_valid(&self, state: &BeaconState, spec: &ChainSpec) {
|
||||
let state_epoch = state.slot.epoch(spec.slots_per_epoch);
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ use slot_clock::SlotClock;
|
||||
use std::sync::Arc;
|
||||
use types::{AttestationData, BeaconBlock, FreeAttestation, Signature, Slot};
|
||||
|
||||
// mod attester;
|
||||
// mod producer;
|
||||
|
||||
/// Connect directly to a borrowed `BeaconChain` instance so an attester/producer can request/submit
|
||||
/// blocks/attestations.
|
||||
///
|
||||
@@ -42,11 +39,6 @@ impl<T: ClientDB, U: SlotClock, F: ForkChoice> DirectBeaconNode<T, U, F> {
|
||||
pub fn last_published_block(&self) -> Option<BeaconBlock> {
|
||||
Some(self.published_blocks.read().last()?.clone())
|
||||
}
|
||||
|
||||
/// Get the last published attestation (if any).
|
||||
pub fn last_published_free_attestation(&self) -> Option<FreeAttestation> {
|
||||
Some(self.published_attestations.read().last()?.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ClientDB, U: SlotClock, F: ForkChoice> AttesterBeaconNode for DirectBeaconNode<T, U, F> {
|
||||
|
||||
@@ -2,8 +2,7 @@ mod direct_beacon_node;
|
||||
mod direct_duties;
|
||||
mod local_signer;
|
||||
|
||||
use attester::PollOutcome as AttestationPollOutcome;
|
||||
use attester::{Attester, Error as AttestationPollError};
|
||||
use attester::Attester;
|
||||
use beacon_chain::BeaconChain;
|
||||
use block_proposer::PollOutcome as BlockPollOutcome;
|
||||
use block_proposer::{BlockProducer, Error as BlockPollError};
|
||||
@@ -14,7 +13,7 @@ use fork_choice::BitwiseLMDGhost;
|
||||
use local_signer::LocalSigner;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use std::sync::Arc;
|
||||
use types::{BeaconBlock, ChainSpec, FreeAttestation, Keypair, Slot};
|
||||
use types::{BeaconBlock, ChainSpec, Keypair, Slot};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum BlockProduceError {
|
||||
@@ -22,12 +21,6 @@ pub enum BlockProduceError {
|
||||
PollError(BlockPollError),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum AttestationProduceError {
|
||||
DidNotProduce(AttestationPollOutcome),
|
||||
PollError(AttestationPollError),
|
||||
}
|
||||
|
||||
type TestingBlockProducer = BlockProducer<
|
||||
TestingSlotClock,
|
||||
DirectBeaconNode<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB>>,
|
||||
@@ -117,21 +110,6 @@ impl ValidatorHarness {
|
||||
.expect("Unable to obtain produced block."))
|
||||
}
|
||||
|
||||
/// Run the `poll` function on the `Attester` and produce a `FreeAttestation`.
|
||||
///
|
||||
/// An error is returned if the attester refuses to attest.
|
||||
pub fn produce_free_attestation(&mut self) -> Result<FreeAttestation, AttestationProduceError> {
|
||||
match self.attester.poll() {
|
||||
Ok(AttestationPollOutcome::AttestationProduced(_)) => {}
|
||||
Ok(outcome) => return Err(AttestationProduceError::DidNotProduce(outcome)),
|
||||
Err(error) => return Err(AttestationProduceError::PollError(error)),
|
||||
};
|
||||
Ok(self
|
||||
.beacon_node
|
||||
.last_published_free_attestation()
|
||||
.expect("Unable to obtain produced attestation."))
|
||||
}
|
||||
|
||||
/// Set the validators slot clock to the specified slot.
|
||||
///
|
||||
/// The validators slot clock will always read this value until it is set to something else.
|
||||
|
||||
Reference in New Issue
Block a user