mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Add reason of NoRequestNeeded to lookup sync (#6317)
* Add reason of NoRequestNeeded to lookup sync * Merge branch 'unstable' into peerdas-reason # Conflicts: # beacon_node/network/src/sync/network_context.rs
This commit is contained in:
@@ -221,11 +221,11 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
|
||||
// with this `req_id`.
|
||||
request.get_state_mut().on_download_start(req_id)?
|
||||
}
|
||||
LookupRequestResult::NoRequestNeeded => {
|
||||
LookupRequestResult::NoRequestNeeded(reason) => {
|
||||
// Lookup sync event safety: Advances this request to the terminal `Processed`
|
||||
// state. If all requests reach this state, the request is marked as completed
|
||||
// in `Self::continue_requests`.
|
||||
request.get_state_mut().on_completed_request()?
|
||||
request.get_state_mut().on_completed_request(reason)?
|
||||
}
|
||||
// Sync will receive a future event to make progress on the request, do nothing now
|
||||
LookupRequestResult::Pending(reason) => {
|
||||
@@ -357,13 +357,13 @@ pub struct DownloadResult<T: Clone> {
|
||||
|
||||
#[derive(IntoStaticStr)]
|
||||
pub enum State<T: Clone> {
|
||||
AwaitingDownload(&'static str),
|
||||
AwaitingDownload(/* reason */ &'static str),
|
||||
Downloading(ReqId),
|
||||
AwaitingProcess(DownloadResult<T>),
|
||||
/// Request is processing, sent by lookup sync
|
||||
Processing(DownloadResult<T>),
|
||||
/// Request is processed
|
||||
Processed,
|
||||
Processed(/* reason */ &'static str),
|
||||
}
|
||||
|
||||
/// Object representing the state of a single block or blob lookup request.
|
||||
@@ -554,7 +554,7 @@ impl<T: Clone> SingleLookupRequestState<T> {
|
||||
pub fn on_processing_success(&mut self) -> Result<(), LookupRequestError> {
|
||||
match &self.state {
|
||||
State::Processing(_) => {
|
||||
self.state = State::Processed;
|
||||
self.state = State::Processed("processing success");
|
||||
Ok(())
|
||||
}
|
||||
other => Err(LookupRequestError::BadState(format!(
|
||||
@@ -564,10 +564,10 @@ impl<T: Clone> SingleLookupRequestState<T> {
|
||||
}
|
||||
|
||||
/// Mark a request as complete without any download or processing
|
||||
pub fn on_completed_request(&mut self) -> Result<(), LookupRequestError> {
|
||||
pub fn on_completed_request(&mut self, reason: &'static str) -> Result<(), LookupRequestError> {
|
||||
match &self.state {
|
||||
State::AwaitingDownload { .. } => {
|
||||
self.state = State::Processed;
|
||||
self.state = State::Processed(reason);
|
||||
Ok(())
|
||||
}
|
||||
other => Err(LookupRequestError::BadState(format!(
|
||||
@@ -598,11 +598,11 @@ impl<T: Clone> std::fmt::Display for State<T> {
|
||||
impl<T: Clone> std::fmt::Debug for State<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::AwaitingDownload(status) => write!(f, "AwaitingDownload({:?})", status),
|
||||
Self::AwaitingDownload(reason) => write!(f, "AwaitingDownload({})", reason),
|
||||
Self::Downloading(req_id) => write!(f, "Downloading({:?})", req_id),
|
||||
Self::AwaitingProcess(d) => write!(f, "AwaitingProcess({:?})", d.peer_group),
|
||||
Self::Processing(d) => write!(f, "Processing({:?})", d.peer_group),
|
||||
Self::Processed { .. } => write!(f, "Processed"),
|
||||
Self::Processed(reason) => write!(f, "Processed({})", reason),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user