-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide
--first
argument for safenode
In the previous setup, if the `network-contacts` feature was enabled, running `safenode` with no `--peer` args caused the peers to be retrieved from the default network contacts file. In the situation where we're launching a genesis node, we don't want this behaviour, and hence we introduce a `--first` flag to make a distinction. The `safenode` binary was changed to remove the use of `unwrap_or` when calling `get_peers_from_args` so that an error will actually occur when peers are not obtainable, rather than swallowing it by returning an empty peer list. The `testnet` binary was also updated to use the `--first` argument when a new network was being created. This necessitated a change to the memcheck workflow, which starts a testnet in a slightly unusual fashion. The `--first` argument had to be applied to the initial node that is launched, and then the subsequent local testnet launch had to be changed to use a join rather than starting a new network. This is because the first peer launched by `testnet`, using `--first`, did not have the initial node launched outside of `testnet` in its peer list. For the test to work correctly, an environment variable was introduced to control the starting port deployment inventory, because using a join network means the port range starts one digit higher. We will be able to remove this when we switch over to using the node manager. BREAKING CHANGE: the `parse_peer_args` function was renamed `get_peers_from_args` and the error handling was changed. The new function name is semantically more accurate, and because `sn_peers_acquisition` is a library crate, we should prefer an `Error` type rather than using `eyre`. Tried to add some unit tests for the `get_peers_from_args` function, but Tokio being an optional dependency proved to be problematic.
- Loading branch information
Showing
16 changed files
with
122 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use thiserror::Error; | ||
|
||
pub type Result<T, E = Error> = std::result::Result<T, E>; | ||
|
||
#[derive(Debug, Error)] | ||
#[allow(missing_docs)] | ||
pub enum Error { | ||
#[error("Could not parse the supplied multiaddr or socket address")] | ||
InvalidPeerAddr, | ||
#[error("Could not obtain network contacts from {0} after {1} retries")] | ||
NetworkContactsUnretrievable(String, usize), | ||
#[error("No valid multaddr was present in the contacts file at {0}")] | ||
NoMultiAddrObtainedFromNetworkContacts(String), | ||
#[error("Could not obtain peers through any available options")] | ||
PeersNotObtained, | ||
#[cfg(feature = "network-contacts")] | ||
#[error(transparent)] | ||
ReqwestError(#[from] reqwest::Error), | ||
#[cfg(feature = "network-contacts")] | ||
#[error(transparent)] | ||
UrlParseError(#[from] url::ParseError), | ||
} |
Oops, something went wrong.