referrerpolicy=no-referrer-when-downgrade

sc_authority_discovery/
error.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Authority discovery errors.
20
21/// AuthorityDiscovery Result.
22pub type Result<T> = std::result::Result<T, Error>;
23
24/// Error type for the authority discovery module.
25#[derive(Debug, thiserror::Error)]
26#[allow(missing_docs)]
27pub enum Error {
28	#[error("Received dht value found event with records with different keys.")]
29	ReceivingDhtValueFoundEventWithDifferentKeys,
30
31	#[error("Received dht value found event with no records.")]
32	ReceivingDhtValueFoundEventWithNoRecords,
33
34	#[error("Failed to verify a dht payload with the given signature.")]
35	VerifyingDhtPayload,
36
37	#[error("Failed to hash the authority id to be used as a dht key.")]
38	HashingAuthorityId(#[from] sc_network_types::multihash::Error),
39
40	#[error("Failed calling into the Substrate runtime: {0}")]
41	CallingRuntime(#[from] sp_blockchain::Error),
42
43	#[error("Received a dht record with a key that does not match any in-flight awaited keys.")]
44	ReceivingUnexpectedRecord,
45
46	#[error("Failed to encode a protobuf payload.")]
47	EncodingProto(#[from] prost::EncodeError),
48
49	#[error("Failed to decode a protobuf payload.")]
50	DecodingProto(#[from] prost::DecodeError),
51
52	#[error("Failed to encode or decode scale payload.")]
53	EncodingDecodingScale(#[from] codec::Error),
54
55	#[error("Failed to encode or decode AddrCache.")]
56	EncodingDecodingAddrCache(String),
57
58	#[error("Failed to parse a libp2p multi address.")]
59	ParsingMultiaddress(#[from] sc_network::multiaddr::ParseError),
60
61	#[error("Failed to parse a libp2p key: {0}")]
62	ParsingLibp2pIdentity(String),
63
64	#[error("Failed to sign: {0}.")]
65	CannotSign(String),
66
67	#[error("Failed to register Prometheus metric.")]
68	Prometheus(#[from] prometheus_endpoint::PrometheusError),
69
70	#[error("Received authority record that contains addresses with multiple peer ids")]
71	ReceivingDhtValueFoundEventWithDifferentPeerIds,
72
73	#[error("Received authority record without any addresses having a peer id")]
74	ReceivingDhtValueFoundEventWithNoPeerIds,
75
76	#[error("Received authority record without a valid signature for the remote peer id.")]
77	MissingPeerIdSignature,
78
79	#[error("Unable to fetch best block.")]
80	BestBlockFetchingError,
81
82	#[error("Publisher not present.")]
83	MissingPublisher,
84
85	#[error("Unknown authority.")]
86	UnknownAuthority,
87}