simplify checking attester cache for block and blobs. use ResourceUnavailable according to the spec

This commit is contained in:
realbigsean
2023-01-24 10:50:47 +01:00
parent e14550425d
commit b658cc7aaf
5 changed files with 66 additions and 82 deletions

View File

@@ -330,6 +330,7 @@ pub struct LightClientBootstrapRequest {
#[strum(serialize_all = "snake_case")]
pub enum RPCResponseErrorCode {
RateLimited,
BlobsNotFoundForBlock,
InvalidRequest,
ServerError,
/// Error spec'd to indicate that a peer does not have blocks on a requested range.
@@ -359,6 +360,7 @@ impl<T: EthSpec> RPCCodedResponse<T> {
2 => RPCResponseErrorCode::ServerError,
3 => RPCResponseErrorCode::ResourceUnavailable,
139 => RPCResponseErrorCode::RateLimited,
142 => RPCResponseErrorCode::BlobsNotFoundForBlock,
_ => RPCResponseErrorCode::Unknown,
};
RPCCodedResponse::Error(code, err)
@@ -397,6 +399,7 @@ impl RPCResponseErrorCode {
RPCResponseErrorCode::ResourceUnavailable => 3,
RPCResponseErrorCode::Unknown => 255,
RPCResponseErrorCode::RateLimited => 139,
RPCResponseErrorCode::BlobsNotFoundForBlock => 140,
}
}
}
@@ -425,6 +428,7 @@ impl std::fmt::Display for RPCResponseErrorCode {
RPCResponseErrorCode::ServerError => "Server error occurred",
RPCResponseErrorCode::Unknown => "Unknown error occurred",
RPCResponseErrorCode::RateLimited => "Rate limited",
RPCResponseErrorCode::BlobsNotFoundForBlock => "No blobs for the given root",
};
f.write_str(repr)
}