mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
Remove generic Id param from RequestId (#6032)
* rename RequestId's for better context, and move them to lighthouse_network crate. * remove unrequired generic AppReqId from RequestID
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
|
||||
use crate::error;
|
||||
use crate::network_beacon_processor::{InvalidBlockStorage, NetworkBeaconProcessor};
|
||||
use crate::service::{NetworkMessage, RequestId};
|
||||
use crate::service::NetworkMessage;
|
||||
use crate::status::status_message;
|
||||
use crate::sync::manager::RequestId as SyncId;
|
||||
use crate::sync::SyncMessage;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use beacon_processor::{
|
||||
@@ -18,6 +17,7 @@ use beacon_processor::{
|
||||
use futures::prelude::*;
|
||||
use lighthouse_network::rpc::*;
|
||||
use lighthouse_network::{
|
||||
service::api_types::{AppRequestId, SyncRequestId},
|
||||
MessageId, NetworkGlobals, PeerId, PeerRequestId, PubsubMessage, Request, Response,
|
||||
};
|
||||
use logging::TimeLatch;
|
||||
@@ -61,13 +61,13 @@ pub enum RouterMessage<E: EthSpec> {
|
||||
/// An RPC response has been received.
|
||||
RPCResponseReceived {
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
response: Response<E>,
|
||||
},
|
||||
/// An RPC request failed
|
||||
RPCFailed {
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
error: RPCError,
|
||||
},
|
||||
/// A gossip message has been received. The fields are: message id, the peer that sent us this
|
||||
@@ -235,7 +235,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
fn handle_rpc_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
response: Response<T::EthSpec>,
|
||||
) {
|
||||
match response {
|
||||
@@ -448,9 +448,9 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
|
||||
/// An error occurred during an RPC request. The state is maintained by the sync manager, so
|
||||
/// this function notifies the sync manager of the error.
|
||||
pub fn on_rpc_error(&mut self, peer_id: PeerId, request_id: RequestId, error: RPCError) {
|
||||
pub fn on_rpc_error(&mut self, peer_id: PeerId, request_id: AppRequestId, error: RPCError) {
|
||||
// Check if the failed RPC belongs to sync
|
||||
if let RequestId::Sync(request_id) = request_id {
|
||||
if let AppRequestId::Sync(request_id) = request_id {
|
||||
self.send_to_sync(SyncMessage::RpcError {
|
||||
peer_id,
|
||||
request_id,
|
||||
@@ -488,18 +488,18 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blocks_by_range_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
beacon_block: Option<Arc<SignedBeaconBlock<T::EthSpec>>>,
|
||||
) {
|
||||
let request_id = match request_id {
|
||||
RequestId::Sync(sync_id) => match sync_id {
|
||||
SyncId::SingleBlock { .. } | SyncId::SingleBlob { .. } => {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
SyncRequestId::SingleBlock { .. } | SyncRequestId::SingleBlob { .. } => {
|
||||
crit!(self.log, "Block lookups do not request BBRange requests"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
id @ SyncId::RangeBlockAndBlobs { .. } => id,
|
||||
id @ SyncRequestId::RangeBlockAndBlobs { .. } => id,
|
||||
},
|
||||
RequestId::Router => {
|
||||
AppRequestId::Router => {
|
||||
crit!(self.log, "All BBRange requests belong to sync"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blobs_by_range_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
blob_sidecar: Option<Arc<BlobSidecar<T::EthSpec>>>,
|
||||
) {
|
||||
trace!(
|
||||
@@ -531,7 +531,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
"peer" => %peer_id,
|
||||
);
|
||||
|
||||
if let RequestId::Sync(id) = request_id {
|
||||
if let AppRequestId::Sync(id) = request_id {
|
||||
self.send_to_sync(SyncMessage::RpcBlob {
|
||||
peer_id,
|
||||
request_id: id,
|
||||
@@ -550,22 +550,22 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blocks_by_root_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
beacon_block: Option<Arc<SignedBeaconBlock<T::EthSpec>>>,
|
||||
) {
|
||||
let request_id = match request_id {
|
||||
RequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncId::SingleBlock { .. } => id,
|
||||
SyncId::RangeBlockAndBlobs { .. } => {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncRequestId::SingleBlock { .. } => id,
|
||||
SyncRequestId::RangeBlockAndBlobs { .. } => {
|
||||
crit!(self.log, "Batch syncing do not request BBRoot requests"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
SyncId::SingleBlob { .. } => {
|
||||
SyncRequestId::SingleBlob { .. } => {
|
||||
crit!(self.log, "Blob response to block by roots request"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
},
|
||||
RequestId::Router => {
|
||||
AppRequestId::Router => {
|
||||
crit!(self.log, "All BBRoot requests belong to sync"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
@@ -588,22 +588,22 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blobs_by_root_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
blob_sidecar: Option<Arc<BlobSidecar<T::EthSpec>>>,
|
||||
) {
|
||||
let request_id = match request_id {
|
||||
RequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncId::SingleBlob { .. } => id,
|
||||
SyncId::SingleBlock { .. } => {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncRequestId::SingleBlob { .. } => id,
|
||||
SyncRequestId::SingleBlock { .. } => {
|
||||
crit!(self.log, "Block response to blobs by roots request"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
SyncId::RangeBlockAndBlobs { .. } => {
|
||||
SyncRequestId::RangeBlockAndBlobs { .. } => {
|
||||
crit!(self.log, "Batch syncing does not request BBRoot requests"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
},
|
||||
RequestId::Router => {
|
||||
AppRequestId::Router => {
|
||||
crit!(self.log, "All BlobsByRoot requests belong to sync"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ impl<E: EthSpec> HandlerNetworkContext<E> {
|
||||
pub fn send_processor_request(&mut self, peer_id: PeerId, request: Request) {
|
||||
self.inform_network(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request_id: RequestId::Router,
|
||||
request_id: AppRequestId::Router,
|
||||
request,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user