Fix clippy lints
This commit is contained in:
parent
1d34e2b2a5
commit
1913be0c6f
@ -497,21 +497,17 @@ where
|
||||
} else {
|
||||
// If the current head block is not from this slot, use the slot from the previous
|
||||
// epoch.
|
||||
let root = *self.state.read().get_block_root(
|
||||
*self.state.read().get_block_root(
|
||||
current_epoch_start_slot - self.spec.slots_per_epoch,
|
||||
&self.spec,
|
||||
)?;
|
||||
|
||||
root
|
||||
)?
|
||||
}
|
||||
} else {
|
||||
// If we're not on the first slot of the epoch.
|
||||
let root = *self
|
||||
*self
|
||||
.state
|
||||
.read()
|
||||
.get_block_root(current_epoch_start_slot, &self.spec)?;
|
||||
|
||||
root
|
||||
.get_block_root(current_epoch_start_slot, &self.spec)?
|
||||
};
|
||||
|
||||
Ok(AttestationData {
|
||||
|
@ -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.
|
||||
|
@ -25,9 +25,9 @@ use tokio::timer::Interval;
|
||||
/// sub-services in multiple threads.
|
||||
pub struct Client<T: ClientTypes> {
|
||||
/// Configuration for the lighthouse client.
|
||||
config: ClientConfig,
|
||||
_config: ClientConfig,
|
||||
/// The beacon chain for the running client.
|
||||
beacon_chain: Arc<BeaconChain<T::DB, T::SlotClock, T::ForkChoice>>,
|
||||
_beacon_chain: Arc<BeaconChain<T::DB, T::SlotClock, T::ForkChoice>>,
|
||||
/// Reference to the network service.
|
||||
pub network: Arc<NetworkService>,
|
||||
/// Signal to terminate the RPC server.
|
||||
@ -90,17 +90,18 @@ impl<TClientType: ClientTypes> Client<TClientType> {
|
||||
network_logger,
|
||||
)?;
|
||||
|
||||
let mut rpc_exit_signal = None;
|
||||
// spawn the RPC server
|
||||
if config.rpc_conf.enabled {
|
||||
rpc_exit_signal = Some(rpc::start_server(
|
||||
let rpc_exit_signal = if config.rpc_conf.enabled {
|
||||
Some(rpc::start_server(
|
||||
&config.rpc_conf,
|
||||
executor,
|
||||
network_send,
|
||||
beacon_chain.clone(),
|
||||
&log,
|
||||
));
|
||||
}
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let (slot_timer_exit_signal, exit) = exit_future::signal();
|
||||
if let Ok(Some(duration_to_next_slot)) = beacon_chain.slot_clock.duration_to_next_slot() {
|
||||
@ -129,8 +130,8 @@ impl<TClientType: ClientTypes> Client<TClientType> {
|
||||
}
|
||||
|
||||
Ok(Client {
|
||||
config,
|
||||
beacon_chain,
|
||||
_config: config,
|
||||
_beacon_chain: beacon_chain,
|
||||
rpc_exit_signal,
|
||||
slot_timer_exit_signal: Some(slot_timer_exit_signal),
|
||||
log,
|
||||
|
@ -14,7 +14,7 @@ pub fn run<T: ClientTypes>(client: &Client<T>, executor: TaskExecutor, exit: Exi
|
||||
// notification heartbeat
|
||||
let interval = Interval::new(Instant::now(), Duration::from_secs(5));
|
||||
|
||||
let log = client.log.new(o!("Service" => "Notifier"));
|
||||
let _log = client.log.new(o!("Service" => "Notifier"));
|
||||
|
||||
// TODO: Debugging only
|
||||
let counter = Arc::new(Mutex::new(0));
|
||||
|
@ -65,17 +65,11 @@ impl<TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess<GossipsubE
|
||||
self.events.push(BehaviourEvent::GossipMessage {
|
||||
source: gs_msg.source,
|
||||
topics: gs_msg.topics,
|
||||
message: pubsub_message,
|
||||
message: Box::new(pubsub_message),
|
||||
});
|
||||
}
|
||||
GossipsubEvent::Subscribed {
|
||||
peer_id: _,
|
||||
topic: _,
|
||||
}
|
||||
| GossipsubEvent::Unsubscribed {
|
||||
peer_id: _,
|
||||
topic: _,
|
||||
} => {}
|
||||
GossipsubEvent::Subscribed { .. } => {}
|
||||
GossipsubEvent::Unsubscribed { .. } => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,7 +104,8 @@ impl<TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess<IdentifyEv
|
||||
);
|
||||
info.listen_addrs.truncate(20);
|
||||
}
|
||||
self.events.push(BehaviourEvent::Identified(peer_id, info));
|
||||
self.events
|
||||
.push(BehaviourEvent::Identified(peer_id, Box::new(info)));
|
||||
}
|
||||
IdentifyEvent::Error { .. } => {}
|
||||
IdentifyEvent::SendBack { .. } => {}
|
||||
@ -183,12 +178,12 @@ impl<TSubstream: AsyncRead + AsyncWrite> Behaviour<TSubstream> {
|
||||
pub enum BehaviourEvent {
|
||||
RPC(PeerId, RPCEvent),
|
||||
PeerDialed(PeerId),
|
||||
Identified(PeerId, IdentifyInfo),
|
||||
Identified(PeerId, Box<IdentifyInfo>),
|
||||
// TODO: This is a stub at the moment
|
||||
GossipMessage {
|
||||
source: PeerId,
|
||||
topics: Vec<TopicHash>,
|
||||
message: PubsubMessage,
|
||||
message: Box<PubsubMessage>,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ pub struct Rpc<TSubstream> {
|
||||
/// Pins the generic substream.
|
||||
marker: PhantomData<TSubstream>,
|
||||
/// Slog logger for RPC behaviour.
|
||||
log: slog::Logger,
|
||||
_log: slog::Logger,
|
||||
}
|
||||
|
||||
impl<TSubstream> Rpc<TSubstream> {
|
||||
@ -35,7 +35,7 @@ impl<TSubstream> Rpc<TSubstream> {
|
||||
Rpc {
|
||||
events: Vec::new(),
|
||||
marker: PhantomData,
|
||||
log,
|
||||
_log: log,
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ where
|
||||
|
||||
fn inject_connected(&mut self, peer_id: PeerId, connected_point: ConnectedPoint) {
|
||||
// if initialised the connection, report this upwards to send the HELLO request
|
||||
if let ConnectedPoint::Dialer { address: _ } = connected_point {
|
||||
if let ConnectedPoint::Dialer { .. } = connected_point {
|
||||
self.events.push(NetworkBehaviourAction::GenerateEvent(
|
||||
RPCMessage::PeerDialed(peer_id),
|
||||
));
|
||||
|
@ -31,7 +31,7 @@ impl Default for RPCProtocol {
|
||||
}
|
||||
|
||||
/// A monotonic counter for ordering `RPCRequest`s.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct RequestId(u64);
|
||||
|
||||
impl RequestId {
|
||||
@ -48,6 +48,12 @@ impl RequestId {
|
||||
|
||||
impl Eq for RequestId {}
|
||||
|
||||
impl PartialEq for RequestId {
|
||||
fn eq(&self, other: &RequestId) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for RequestId {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.0.hash(state);
|
||||
@ -104,17 +110,15 @@ impl UpgradeInfo for RPCEvent {
|
||||
}
|
||||
}
|
||||
|
||||
type FnDecodeRPCEvent = fn(Vec<u8>, ()) -> Result<RPCEvent, DecodeError>;
|
||||
|
||||
impl<TSocket> InboundUpgrade<TSocket> for RPCProtocol
|
||||
where
|
||||
TSocket: AsyncRead + AsyncWrite,
|
||||
{
|
||||
type Output = RPCEvent;
|
||||
type Error = DecodeError;
|
||||
type Future = upgrade::ReadOneThen<
|
||||
upgrade::Negotiated<TSocket>,
|
||||
(),
|
||||
fn(Vec<u8>, ()) -> Result<RPCEvent, DecodeError>,
|
||||
>;
|
||||
type Future = upgrade::ReadOneThen<upgrade::Negotiated<TSocket>, (), FnDecodeRPCEvent>;
|
||||
|
||||
fn upgrade_inbound(self, socket: upgrade::Negotiated<TSocket>, _: Self::Info) -> Self::Future {
|
||||
upgrade::read_one_then(socket, MAX_READ_SIZE, (), |packet, ()| Ok(decode(packet)?))
|
||||
|
@ -19,13 +19,16 @@ use std::io::{Error, ErrorKind};
|
||||
use std::time::Duration;
|
||||
use types::{TopicBuilder, TopicHash};
|
||||
|
||||
type Libp2pStream = Boxed<(PeerId, StreamMuxerBox), Error>;
|
||||
type Libp2pBehaviour = Behaviour<Substream<StreamMuxerBox>>;
|
||||
|
||||
/// The configuration and state of the libp2p components for the beacon node.
|
||||
pub struct Service {
|
||||
/// The libp2p Swarm handler.
|
||||
//TODO: Make this private
|
||||
pub swarm: Swarm<Boxed<(PeerId, StreamMuxerBox), Error>, Behaviour<Substream<StreamMuxerBox>>>,
|
||||
pub swarm: Swarm<Libp2pStream, Libp2pBehaviour>,
|
||||
/// This node's PeerId.
|
||||
local_peer_id: PeerId,
|
||||
_local_peer_id: PeerId,
|
||||
/// The libp2p logger handle.
|
||||
pub log: slog::Logger,
|
||||
}
|
||||
@ -89,7 +92,7 @@ impl Service {
|
||||
info!(log, "Subscribed to topics: {:?}", subscribed_topics);
|
||||
|
||||
Ok(Service {
|
||||
local_peer_id,
|
||||
_local_peer_id: local_peer_id,
|
||||
swarm,
|
||||
log,
|
||||
})
|
||||
@ -179,11 +182,11 @@ pub enum Libp2pEvent {
|
||||
/// Initiated the connection to a new peer.
|
||||
PeerDialed(PeerId),
|
||||
/// Received information about a peer on the network.
|
||||
Identified(PeerId, IdentifyInfo),
|
||||
Identified(PeerId, Box<IdentifyInfo>),
|
||||
/// Received pubsub message.
|
||||
PubsubMessage {
|
||||
source: PeerId,
|
||||
topics: Vec<TopicHash>,
|
||||
message: PubsubMessage,
|
||||
message: Box<PubsubMessage>,
|
||||
},
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pub enum HandlerMessage {
|
||||
/// An RPC response/request has been received.
|
||||
RPC(PeerId, RPCEvent),
|
||||
/// A gossip message has been received.
|
||||
PubsubMessage(PeerId, PubsubMessage),
|
||||
PubsubMessage(PeerId, Box<PubsubMessage>),
|
||||
}
|
||||
|
||||
impl MessageHandler {
|
||||
@ -93,7 +93,7 @@ impl MessageHandler {
|
||||
}
|
||||
// we have received an RPC message request/response
|
||||
HandlerMessage::PubsubMessage(peer_id, gossip) => {
|
||||
self.handle_gossip(peer_id, gossip);
|
||||
self.handle_gossip(peer_id, *gossip);
|
||||
}
|
||||
//TODO: Handle all messages
|
||||
_ => {}
|
||||
|
@ -17,7 +17,7 @@ use types::Topic;
|
||||
/// Service that handles communication between internal services and the eth2_libp2p network service.
|
||||
pub struct Service {
|
||||
//libp2p_service: Arc<Mutex<LibP2PService>>,
|
||||
libp2p_exit: oneshot::Sender<()>,
|
||||
_libp2p_exit: oneshot::Sender<()>,
|
||||
network_send: crossbeam_channel::Sender<NetworkMessage>,
|
||||
//message_handler: MessageHandler,
|
||||
//message_handler_send: Sender<HandlerMessage>,
|
||||
@ -54,7 +54,7 @@ impl Service {
|
||||
log,
|
||||
)?;
|
||||
let network_service = Service {
|
||||
libp2p_exit,
|
||||
_libp2p_exit: libp2p_exit,
|
||||
network_send: network_send.clone(),
|
||||
};
|
||||
|
||||
@ -131,9 +131,7 @@ fn network_service(
|
||||
);
|
||||
}
|
||||
Libp2pEvent::PubsubMessage {
|
||||
source,
|
||||
topics: _,
|
||||
message,
|
||||
source, message, ..
|
||||
} => {
|
||||
//TODO: Decide if we need to propagate the topic upwards. (Potentially for
|
||||
//attestations)
|
||||
@ -167,7 +165,7 @@ fn network_service(
|
||||
}
|
||||
Ok(NetworkMessage::Publish { topics, message }) => {
|
||||
debug!(log, "Sending pubsub message on topics {:?}", topics);
|
||||
libp2p_service.swarm.publish(topics, message);
|
||||
libp2p_service.swarm.publish(topics, *message);
|
||||
}
|
||||
Err(TryRecvError::Empty) => break,
|
||||
Err(TryRecvError::Disconnected) => {
|
||||
@ -190,7 +188,7 @@ pub enum NetworkMessage {
|
||||
/// Publish a message to pubsub mechanism.
|
||||
Publish {
|
||||
topics: Vec<Topic>,
|
||||
message: PubsubMessage,
|
||||
message: Box<PubsubMessage>,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ pub enum PeerStatus {
|
||||
}
|
||||
|
||||
impl PeerStatus {
|
||||
pub fn should_handshake(&self) -> bool {
|
||||
pub fn should_handshake(self) -> bool {
|
||||
match self {
|
||||
PeerStatus::DifferentNetworkId => false,
|
||||
PeerStatus::FinalizedEpochNotInChain => false,
|
||||
|
@ -43,9 +43,9 @@ impl AttestationService for AttestationServiceInstance {
|
||||
let f = sink
|
||||
.fail(RpcStatus::new(
|
||||
RpcStatusCode::OutOfRange,
|
||||
Some(format!(
|
||||
"AttestationData request for a slot that is in the future."
|
||||
)),
|
||||
Some(
|
||||
"AttestationData request for a slot that is in the future.".to_string(),
|
||||
),
|
||||
))
|
||||
.map_err(move |e| {
|
||||
error!(log_clone, "Failed to reply with failure {:?}: {:?}", req, e)
|
||||
@ -58,9 +58,7 @@ impl AttestationService for AttestationServiceInstance {
|
||||
let f = sink
|
||||
.fail(RpcStatus::new(
|
||||
RpcStatusCode::InvalidArgument,
|
||||
Some(format!(
|
||||
"AttestationData request for a slot that is in the past."
|
||||
)),
|
||||
Some("AttestationData request for a slot that is in the past.".to_string()),
|
||||
))
|
||||
.map_err(move |e| {
|
||||
error!(log_clone, "Failed to reply with failure {:?}: {:?}", req, e)
|
||||
|
@ -43,7 +43,7 @@ impl BeaconBlockService for BeaconBlockServiceInstance {
|
||||
let f = sink
|
||||
.fail(RpcStatus::new(
|
||||
RpcStatusCode::InvalidArgument,
|
||||
Some(format!("Invalid randao reveal signature")),
|
||||
Some("Invalid randao reveal signature".to_string()),
|
||||
))
|
||||
.map_err(move |e| warn!(log_clone, "failed to reply {:?}: {:?}", req, e));
|
||||
return ctx.spawn(f);
|
||||
@ -114,7 +114,7 @@ impl BeaconBlockService for BeaconBlockServiceInstance {
|
||||
self.network_chan
|
||||
.send(NetworkMessage::Publish {
|
||||
topics: vec![topic],
|
||||
message,
|
||||
message: Box::new(message),
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
error!(
|
||||
|
@ -24,7 +24,7 @@ impl BeaconNodeService for BeaconNodeServiceInstance {
|
||||
// get the chain state
|
||||
let state = self.chain.get_state();
|
||||
let state_fork = state.fork.clone();
|
||||
let genesis_time = state.genesis_time.clone();
|
||||
let genesis_time = state.genesis_time;
|
||||
|
||||
// build the rpc fork struct
|
||||
let mut fork = Fork::new();
|
||||
@ -35,7 +35,7 @@ impl BeaconNodeService for BeaconNodeServiceInstance {
|
||||
node_info.set_fork(fork);
|
||||
node_info.set_genesis_time(genesis_time);
|
||||
node_info.set_genesis_slot(self.chain.get_spec().genesis_slot.as_u64());
|
||||
node_info.set_chain_id(self.chain.get_spec().chain_id as u32);
|
||||
node_info.set_chain_id(u32::from(self.chain.get_spec().chain_id));
|
||||
|
||||
// send the node_info the requester
|
||||
let error_log = self.log.clone();
|
||||
|
@ -82,8 +82,7 @@ fn run_state_transition_tests_small() {
|
||||
for block in test_case.blocks.iter() {
|
||||
while block.slot > state.slot {
|
||||
let latest_block_header = state.latest_block_header.clone();
|
||||
let res = per_slot_processing(&mut state, &latest_block_header, &test_case.config)
|
||||
.unwrap();
|
||||
per_slot_processing(&mut state, &latest_block_header, &test_case.config).unwrap();
|
||||
}
|
||||
if test_case.verify_signatures {
|
||||
let res = per_block_processing(&mut state, &block, &test_case.config);
|
||||
|
@ -6,8 +6,7 @@ use dirs;
|
||||
use log::debug;
|
||||
use rayon::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
//TODO: testing only
|
||||
use std::time::{Duration, SystemTime};
|
||||
use std::time::SystemTime;
|
||||
|
||||
pub const KEYPAIRS_FILE: &str = "keypairs.raw_keypairs";
|
||||
|
||||
|
@ -3,7 +3,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Eq, Serialize, Deserialize)]
|
||||
pub struct Keypair {
|
||||
pub sk: SecretKey,
|
||||
pub pk: PublicKey,
|
||||
@ -22,6 +22,12 @@ impl Keypair {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Keypair {
|
||||
fn eq(&self, other: &Keypair) -> bool {
|
||||
self == other
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for Keypair {
|
||||
/// Note: this is distinct from consensus serialization, it will produce a different hash.
|
||||
///
|
||||
|
@ -81,6 +81,7 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Try to load keys from validator_dir, returning None if none are found or an error.
|
||||
#[allow(dead_code)]
|
||||
pub fn fetch_keys(&self, log: &slog::Logger) -> Option<Vec<Keypair>> {
|
||||
let key_pairs: Vec<Keypair> = fs::read_dir(&self.data_dir)
|
||||
.unwrap()
|
||||
@ -144,6 +145,7 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Saves a keypair to a file inside the appropriate validator directory. Returns the saved path filename.
|
||||
#[allow(dead_code)]
|
||||
pub fn save_key(&self, key: &Keypair) -> Result<PathBuf, Error> {
|
||||
let validator_config_path = self.data_dir.join(key.identifier());
|
||||
let key_path = validator_config_path.join(DEFAULT_PRIVATE_KEY_FILENAME);
|
||||
|
@ -29,7 +29,7 @@ use std::sync::RwLock;
|
||||
use std::time::{Duration, Instant, SystemTime};
|
||||
use tokio::prelude::*;
|
||||
use tokio::runtime::Builder;
|
||||
use tokio::timer::{Delay, Interval};
|
||||
use tokio::timer::Interval;
|
||||
use tokio_timer::clock::Clock;
|
||||
use types::test_utils::generate_deterministic_keypairs;
|
||||
use types::{ChainSpec, Epoch, Fork, Slot};
|
||||
|
Loading…
Reference in New Issue
Block a user