mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Silence some alerts due to overly verbose warnings. (#3946)
* statement-distribution: Only warn on relevant stuff. * Silence warnings in availability-distribution. * Demote more warnings. * More consistency. * info -> debug
This commit is contained in:
@@ -87,8 +87,12 @@ pub enum NonFatal {
|
||||
#[error("Relay parent could not be found in active heads")]
|
||||
NoSuchHead(Hash),
|
||||
|
||||
/// Received message from actually disconnected peer.
|
||||
#[error("Message from not connected peer")]
|
||||
NoSuchPeer(PeerId),
|
||||
|
||||
/// Peer requested statement data for candidate that was never announced to it.
|
||||
#[error("Peer requested data for candidate it never received a notification for")]
|
||||
#[error("Peer requested data for candidate it never received a notification for (malicious?)")]
|
||||
RequestedUnannouncedCandidate(PeerId, CandidateHash),
|
||||
|
||||
/// A large statement status was requested, which could not be found.
|
||||
@@ -112,7 +116,11 @@ pub fn log_error(result: Result<()>, ctx: &'static str) -> std::result::Result<(
|
||||
match result {
|
||||
Err(Error::Fatal(f)) => Err(f),
|
||||
Err(Error::NonFatal(error)) => {
|
||||
tracing::warn!(target: LOG_TARGET, error = ?error, ctx);
|
||||
match error {
|
||||
NonFatal::RequestedUnannouncedCandidate(_, _) =>
|
||||
tracing::warn!(target: LOG_TARGET, error = %error, ctx),
|
||||
_ => tracing::debug!(target: LOG_TARGET, error = %error, ctx),
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
Ok(()) => Ok(()),
|
||||
|
||||
@@ -1625,7 +1625,7 @@ impl StatementDistribution {
|
||||
&requesting_peer,
|
||||
&relay_parent,
|
||||
&candidate_hash,
|
||||
) {
|
||||
)? {
|
||||
return Err(NonFatal::RequestedUnannouncedCandidate(
|
||||
requesting_peer,
|
||||
candidate_hash,
|
||||
@@ -1896,27 +1896,15 @@ fn requesting_peer_knows_about_candidate(
|
||||
requesting_peer: &PeerId,
|
||||
relay_parent: &Hash,
|
||||
candidate_hash: &CandidateHash,
|
||||
) -> bool {
|
||||
requesting_peer_knows_about_candidate_inner(
|
||||
peers,
|
||||
requesting_peer,
|
||||
relay_parent,
|
||||
candidate_hash,
|
||||
)
|
||||
.is_some()
|
||||
}
|
||||
|
||||
/// Helper function for `requesting_peer_knows_about_statement`.
|
||||
fn requesting_peer_knows_about_candidate_inner(
|
||||
peers: &HashMap<PeerId, PeerData>,
|
||||
requesting_peer: &PeerId,
|
||||
relay_parent: &Hash,
|
||||
candidate_hash: &CandidateHash,
|
||||
) -> Option<()> {
|
||||
let peer_data = peers.get(requesting_peer)?;
|
||||
let knowledge = peer_data.view_knowledge.get(relay_parent)?;
|
||||
knowledge.sent_candidates.get(&candidate_hash)?;
|
||||
Some(())
|
||||
) -> NonFatalResult<bool> {
|
||||
let peer_data = peers
|
||||
.get(requesting_peer)
|
||||
.ok_or_else(|| NonFatal::NoSuchPeer(*requesting_peer))?;
|
||||
let knowledge = peer_data
|
||||
.view_knowledge
|
||||
.get(relay_parent)
|
||||
.ok_or_else(|| NonFatal::NoSuchHead(*relay_parent))?;
|
||||
Ok(knowledge.sent_candidates.get(&candidate_hash).is_some())
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
Reference in New Issue
Block a user