mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Merge branch 'master' into sos
This commit is contained in:
@@ -12,12 +12,12 @@ use std::sync::Arc;
|
||||
use types::{Attestation, EthSpec};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AttestationServiceInstance<B: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<B>>,
|
||||
pub struct AttestationServiceInstance<E: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<E>>,
|
||||
pub log: slog::Logger,
|
||||
}
|
||||
|
||||
impl<B: EthSpec> AttestationService for AttestationServiceInstance<B> {
|
||||
impl<E: EthSpec> AttestationService for AttestationServiceInstance<E> {
|
||||
/// Produce the `AttestationData` for signing by a validator.
|
||||
fn produce_attestation_data(
|
||||
&mut self,
|
||||
|
||||
@@ -16,13 +16,13 @@ use std::sync::Arc;
|
||||
use types::{BeaconBlock, EthSpec, Signature, Slot};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BeaconBlockServiceInstance<B: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<B>>,
|
||||
pub struct BeaconBlockServiceInstance<E: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<E>>,
|
||||
pub network_chan: crossbeam_channel::Sender<NetworkMessage>,
|
||||
pub log: Logger,
|
||||
}
|
||||
|
||||
impl<B: EthSpec> BeaconBlockService for BeaconBlockServiceInstance<B> {
|
||||
impl<E: EthSpec> BeaconBlockService for BeaconBlockServiceInstance<E> {
|
||||
/// Produce a `BeaconBlock` for signing by a validator.
|
||||
fn produce_beacon_block(
|
||||
&mut self,
|
||||
|
||||
@@ -11,12 +11,12 @@ pub use beacon_chain::{BeaconChainError, BlockProcessingOutcome};
|
||||
use types::{Attestation, AttestationData, BeaconBlock, EthSpec};
|
||||
|
||||
/// The RPC's API to the beacon chain.
|
||||
pub trait BeaconChain<B: EthSpec>: Send + Sync {
|
||||
pub trait BeaconChain<E: EthSpec>: Send + Sync {
|
||||
fn get_spec(&self) -> &ChainSpec;
|
||||
|
||||
fn get_state(&self) -> RwLockReadGuard<BeaconState<B>>;
|
||||
fn get_state(&self) -> RwLockReadGuard<BeaconState<E>>;
|
||||
|
||||
fn get_mut_state(&self) -> RwLockWriteGuard<BeaconState<B>>;
|
||||
fn get_mut_state(&self) -> RwLockWriteGuard<BeaconState<E>>;
|
||||
|
||||
fn process_block(&self, block: BeaconBlock)
|
||||
-> Result<BlockProcessingOutcome, BeaconChainError>;
|
||||
@@ -24,7 +24,7 @@ pub trait BeaconChain<B: EthSpec>: Send + Sync {
|
||||
fn produce_block(
|
||||
&self,
|
||||
randao_reveal: Signature,
|
||||
) -> Result<(BeaconBlock, BeaconState<B>), BlockProductionError>;
|
||||
) -> Result<(BeaconBlock, BeaconState<E>), BlockProductionError>;
|
||||
|
||||
fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, BeaconChainError>;
|
||||
|
||||
@@ -34,22 +34,22 @@ pub trait BeaconChain<B: EthSpec>: Send + Sync {
|
||||
) -> Result<(), AttestationValidationError>;
|
||||
}
|
||||
|
||||
impl<T, U, F, B> BeaconChain<B> for RawBeaconChain<T, U, F, B>
|
||||
impl<T, U, F, E> BeaconChain<E> for RawBeaconChain<T, U, F, E>
|
||||
where
|
||||
T: ClientDB + Sized,
|
||||
U: SlotClock,
|
||||
F: ForkChoice,
|
||||
B: EthSpec,
|
||||
E: EthSpec,
|
||||
{
|
||||
fn get_spec(&self) -> &ChainSpec {
|
||||
&self.spec
|
||||
}
|
||||
|
||||
fn get_state(&self) -> RwLockReadGuard<BeaconState<B>> {
|
||||
fn get_state(&self) -> RwLockReadGuard<BeaconState<E>> {
|
||||
self.state.read()
|
||||
}
|
||||
|
||||
fn get_mut_state(&self) -> RwLockWriteGuard<BeaconState<B>> {
|
||||
fn get_mut_state(&self) -> RwLockWriteGuard<BeaconState<E>> {
|
||||
self.state.write()
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ where
|
||||
fn produce_block(
|
||||
&self,
|
||||
randao_reveal: Signature,
|
||||
) -> Result<(BeaconBlock, BeaconState<B>), BlockProductionError> {
|
||||
) -> Result<(BeaconBlock, BeaconState<E>), BlockProductionError> {
|
||||
self.produce_block(randao_reveal)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ use std::sync::Arc;
|
||||
use types::EthSpec;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BeaconNodeServiceInstance<B: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<B>>,
|
||||
pub struct BeaconNodeServiceInstance<E: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<E>>,
|
||||
pub log: slog::Logger,
|
||||
}
|
||||
|
||||
impl<B: EthSpec> BeaconNodeService for BeaconNodeServiceInstance<B> {
|
||||
impl<E: EthSpec> BeaconNodeService for BeaconNodeServiceInstance<E> {
|
||||
/// Provides basic node information.
|
||||
fn info(&mut self, ctx: RpcContext, _req: Empty, sink: UnarySink<NodeInfoResponse>) {
|
||||
trace!(self.log, "Node info requested via RPC");
|
||||
|
||||
@@ -23,11 +23,11 @@ use std::sync::Arc;
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use types::EthSpec;
|
||||
|
||||
pub fn start_server<B: EthSpec>(
|
||||
pub fn start_server<E: EthSpec>(
|
||||
config: &RPCConfig,
|
||||
executor: &TaskExecutor,
|
||||
network_chan: crossbeam_channel::Sender<NetworkMessage>,
|
||||
beacon_chain: Arc<BeaconChain<B>>,
|
||||
beacon_chain: Arc<BeaconChain<E>>,
|
||||
log: &slog::Logger,
|
||||
) -> exit_future::Signal {
|
||||
let log = log.new(o!("Service"=>"RPC"));
|
||||
|
||||
@@ -10,13 +10,13 @@ use std::sync::Arc;
|
||||
use types::{Epoch, EthSpec, RelativeEpoch};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ValidatorServiceInstance<B: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<B>>,
|
||||
pub struct ValidatorServiceInstance<E: EthSpec> {
|
||||
pub chain: Arc<BeaconChain<E>>,
|
||||
pub log: slog::Logger,
|
||||
}
|
||||
//TODO: Refactor Errors
|
||||
|
||||
impl<B: EthSpec> ValidatorService for ValidatorServiceInstance<B> {
|
||||
impl<E: EthSpec> ValidatorService for ValidatorServiceInstance<E> {
|
||||
/// For a list of validator public keys, this function returns the slot at which each
|
||||
/// validator must propose a block, attest to a shard, their shard committee and the shard they
|
||||
/// need to attest to.
|
||||
|
||||
Reference in New Issue
Block a user