mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Fix compile issues and modify type names
This commit is contained in:
@@ -6,4 +6,5 @@ pub mod service;
|
||||
pub mod sync;
|
||||
|
||||
pub use eth2_libp2p::NetworkConfig;
|
||||
pub use service::NetworkMessage;
|
||||
pub use service::Service;
|
||||
|
||||
@@ -165,9 +165,9 @@ fn network_service(
|
||||
}
|
||||
};
|
||||
}
|
||||
Ok(NetworkMessage::Publish(topic, message)) => {
|
||||
debug!(log, "Sending pubsub message on topic {:?}", topic);
|
||||
libp2p_service.swarm.publish(topic, message);
|
||||
Ok(NetworkMessage::Publish { topics, message }) => {
|
||||
debug!(log, "Sending pubsub message on topics {:?}", topics);
|
||||
libp2p_service.swarm.publish(topics, message);
|
||||
}
|
||||
Err(TryRecvError::Empty) => break,
|
||||
Err(TryRecvError::Disconnected) => {
|
||||
@@ -188,7 +188,10 @@ pub enum NetworkMessage {
|
||||
//TODO: Define typing for messages across the wire
|
||||
Send(PeerId, OutgoingMessage),
|
||||
/// Publish a message to pubsub mechanism.
|
||||
Publish(Topic, PubsubMessage),
|
||||
Publish {
|
||||
topics: Vec<Topic>,
|
||||
message: PubsubMessage,
|
||||
},
|
||||
}
|
||||
|
||||
/// Type of outgoing messages that can be sent through the network service.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use super::import_queue::ImportQueue;
|
||||
use crate::beacon_chain::BeaconChain;
|
||||
use crate::message_handler::NetworkContext;
|
||||
use eth2_libp2p::behaviour::{AttestationGossip, BlockGossip};
|
||||
use eth2_libp2p::rpc::methods::*;
|
||||
use eth2_libp2p::rpc::{RPCRequest, RPCResponse, RequestId};
|
||||
use eth2_libp2p::PeerId;
|
||||
@@ -9,7 +8,7 @@ use slog::{debug, error, info, o, warn};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use types::{Epoch, Hash256, Slot};
|
||||
use types::{Attestation, Epoch, Hash256, Slot};
|
||||
|
||||
/// The number of slots that we can import blocks ahead of us, before going into full Sync mode.
|
||||
const SLOT_IMPORT_TOLERANCE: u64 = 100;
|
||||
@@ -521,12 +520,12 @@ impl SimpleSync {
|
||||
pub fn on_block_gossip(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
msg: BlockGossip,
|
||||
msg: BlockRootSlot,
|
||||
network: &mut NetworkContext,
|
||||
) {
|
||||
debug!(
|
||||
self.log,
|
||||
"BlockGossip";
|
||||
"BlockSlot";
|
||||
"peer" => format!("{:?}", peer_id),
|
||||
);
|
||||
// TODO: filter out messages that a prior to the finalized slot.
|
||||
@@ -535,12 +534,12 @@ impl SimpleSync {
|
||||
// now.
|
||||
//
|
||||
// Note: only requests the new block -- will fail if we don't have its parents.
|
||||
if self.import_queue.is_new_block(&msg.root.block_root) {
|
||||
if self.import_queue.is_new_block(&msg.block_root) {
|
||||
self.request_block_headers(
|
||||
peer_id,
|
||||
BeaconBlockHeadersRequest {
|
||||
start_root: msg.root.block_root,
|
||||
start_slot: msg.root.slot,
|
||||
start_root: msg.block_root,
|
||||
start_slot: msg.slot,
|
||||
max_headers: 1,
|
||||
skip_slots: 0,
|
||||
},
|
||||
@@ -555,19 +554,19 @@ impl SimpleSync {
|
||||
pub fn on_attestation_gossip(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
msg: AttestationGossip,
|
||||
msg: Attestation,
|
||||
_network: &mut NetworkContext,
|
||||
) {
|
||||
debug!(
|
||||
self.log,
|
||||
"AttestationGossip";
|
||||
"Attestation";
|
||||
"peer" => format!("{:?}", peer_id),
|
||||
);
|
||||
|
||||
// Awaiting a proper operations pool before we can import attestations.
|
||||
//
|
||||
// https://github.com/sigp/lighthouse/issues/281
|
||||
match self.chain.process_attestation(msg.attestation) {
|
||||
match self.chain.process_attestation(msg) {
|
||||
Ok(_) => panic!("Impossible, method not implemented."),
|
||||
Err(_) => error!(self.log, "Attestation processing not implemented!"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user