mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-28 14:57:17 +00:00
Make BeaconChainTypes Send + Sync + 'static
This commit is contained in:
parent
5a34f86e77
commit
853344af8a
@ -77,7 +77,7 @@ pub enum AttestationProcessingOutcome {
|
||||
Invalid(AttestationValidationError),
|
||||
}
|
||||
|
||||
pub trait BeaconChainTypes {
|
||||
pub trait BeaconChainTypes: Send + Sync + 'static {
|
||||
type Store: store::Store;
|
||||
type SlotClock: slot_clock::SlotClock;
|
||||
type LmdGhost: LmdGhost<Self::Store, Self::EthSpec>;
|
||||
|
@ -54,8 +54,8 @@ where
|
||||
|
||||
impl<L, E> BeaconChainTypes for CommonTypes<L, E>
|
||||
where
|
||||
L: LmdGhost<MemoryStore, E>,
|
||||
E: EthSpec,
|
||||
L: LmdGhost<MemoryStore, E> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
{
|
||||
type Store = MemoryStore;
|
||||
type SlotClock = TestingSlotClock;
|
||||
@ -69,8 +69,8 @@ where
|
||||
/// Used for testing.
|
||||
pub struct BeaconChainHarness<L, E>
|
||||
where
|
||||
L: LmdGhost<MemoryStore, E>,
|
||||
E: EthSpec,
|
||||
L: LmdGhost<MemoryStore, E> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
{
|
||||
pub chain: BeaconChain<CommonTypes<L, E>>,
|
||||
pub keypairs: Vec<Keypair>,
|
||||
|
@ -36,7 +36,11 @@ pub struct ClientType<S: Store, E: EthSpec> {
|
||||
_phantom_u: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<S: Store, E: EthSpec + Clone> BeaconChainTypes for ClientType<S, E> {
|
||||
impl<S, E> BeaconChainTypes for ClientType<S, E>
|
||||
where
|
||||
S: Store + 'static,
|
||||
E: EthSpec + 'static + Clone,
|
||||
{
|
||||
type Store = S;
|
||||
type SlotClock = SystemTimeSlotClock;
|
||||
type LmdGhost = ThreadSafeReducedTree<S, E>;
|
||||
|
@ -49,7 +49,7 @@ pub struct Client<T: BeaconChainTypes> {
|
||||
|
||||
impl<T> Client<T>
|
||||
where
|
||||
T: BeaconChainTypes + InitialiseBeaconChain<T> + Clone + Send + Sync + 'static,
|
||||
T: BeaconChainTypes + InitialiseBeaconChain<T> + Clone,
|
||||
{
|
||||
/// Generate an instance of the client. Spawn and link all internal sub-processes.
|
||||
pub fn new(
|
||||
|
@ -17,11 +17,7 @@ pub const WARN_PEER_COUNT: usize = 1;
|
||||
/// durations.
|
||||
///
|
||||
/// Presently unused, but remains for future use.
|
||||
pub fn run<T: BeaconChainTypes + Send + Sync + 'static>(
|
||||
client: &Client<T>,
|
||||
executor: TaskExecutor,
|
||||
exit: Exit,
|
||||
) {
|
||||
pub fn run<T: BeaconChainTypes>(client: &Client<T>, executor: TaskExecutor, exit: Exit) {
|
||||
// notification heartbeat
|
||||
let interval = Interval::new(
|
||||
Instant::now(),
|
||||
|
@ -71,7 +71,7 @@ impl From<state_processing::per_slot_processing::Error> for ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start_server<T: BeaconChainTypes + Clone + Send + Sync + 'static>(
|
||||
pub fn start_server<T: BeaconChainTypes>(
|
||||
config: &ApiConfig,
|
||||
executor: &TaskExecutor,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
|
@ -7,9 +7,7 @@ use std::sync::Arc;
|
||||
/// HTTP handle to return the list of libp2p multiaddr the client is listening on.
|
||||
///
|
||||
/// Returns a list of `Multiaddr`, serialized according to their `serde` impl.
|
||||
pub fn get_listen_addresses<T: BeaconChainTypes + Send + Sync + 'static>(
|
||||
req: Request<Body>,
|
||||
) -> ApiResult {
|
||||
pub fn get_listen_addresses<T: BeaconChainTypes>(req: Request<Body>) -> ApiResult {
|
||||
let network = req
|
||||
.extensions()
|
||||
.get::<Arc<NetworkService<T>>>()
|
||||
@ -26,7 +24,7 @@ pub fn get_listen_addresses<T: BeaconChainTypes + Send + Sync + 'static>(
|
||||
/// HTTP handle to return the Discv5 ENR from the client's libp2p service.
|
||||
///
|
||||
/// ENR is encoded as base64 string.
|
||||
pub fn get_enr<T: BeaconChainTypes + Send + Sync + 'static>(req: Request<Body>) -> ApiResult {
|
||||
pub fn get_enr<T: BeaconChainTypes>(req: Request<Body>) -> ApiResult {
|
||||
let network = req
|
||||
.extensions()
|
||||
.get::<Arc<NetworkService<T>>>()
|
||||
@ -43,7 +41,7 @@ pub fn get_enr<T: BeaconChainTypes + Send + Sync + 'static>(req: Request<Body>)
|
||||
/// HTTP handle to return the `PeerId` from the client's libp2p service.
|
||||
///
|
||||
/// PeerId is encoded as base58 string.
|
||||
pub fn get_peer_id<T: BeaconChainTypes + Send + Sync + 'static>(req: Request<Body>) -> ApiResult {
|
||||
pub fn get_peer_id<T: BeaconChainTypes>(req: Request<Body>) -> ApiResult {
|
||||
let network = req
|
||||
.extensions()
|
||||
.get::<Arc<NetworkService<T>>>()
|
||||
@ -58,9 +56,7 @@ pub fn get_peer_id<T: BeaconChainTypes + Send + Sync + 'static>(req: Request<Bod
|
||||
}
|
||||
|
||||
/// HTTP handle to return the number of peers connected in the client's libp2p service.
|
||||
pub fn get_peer_count<T: BeaconChainTypes + Send + Sync + 'static>(
|
||||
req: Request<Body>,
|
||||
) -> ApiResult {
|
||||
pub fn get_peer_count<T: BeaconChainTypes>(req: Request<Body>) -> ApiResult {
|
||||
let network = req
|
||||
.extensions()
|
||||
.get::<Arc<NetworkService<T>>>()
|
||||
@ -77,7 +73,7 @@ pub fn get_peer_count<T: BeaconChainTypes + Send + Sync + 'static>(
|
||||
/// HTTP handle to return the list of peers connected to the client's libp2p service.
|
||||
///
|
||||
/// Peers are presented as a list of `PeerId::to_string()`.
|
||||
pub fn get_peer_list<T: BeaconChainTypes + Send + Sync + 'static>(req: Request<Body>) -> ApiResult {
|
||||
pub fn get_peer_list<T: BeaconChainTypes>(req: Request<Body>) -> ApiResult {
|
||||
let network = req
|
||||
.extensions()
|
||||
.get::<Arc<NetworkService<T>>>()
|
||||
|
@ -118,7 +118,7 @@ fn run<T>(
|
||||
log: &slog::Logger,
|
||||
) -> error::Result<()>
|
||||
where
|
||||
T: BeaconChainTypes + InitialiseBeaconChain<T> + Clone + Send + Sync + 'static,
|
||||
T: BeaconChainTypes + InitialiseBeaconChain<T> + Clone,
|
||||
T::Store: OpenDatabase,
|
||||
{
|
||||
let store = T::Store::open_database(&db_path)?;
|
||||
|
Loading…
Reference in New Issue
Block a user