Skip to content

Commit

Permalink
feat: define different network defaults for bins (#5307)
Browse files Browse the repository at this point in the history
Description
---
This commit make a simple switch to define Network::default differently
for the different bins compiled for different networks.

Motivation and Context
---
Making us one step closer to smarter defaults, and one click, out of the
box.

How Has This Been Tested?
---
Manually

What process can a PR reviewer use to test or verify this change?
---
Compile the bin with `TARI_NETWORK=...` then validate the bin uses the
correct default

Fixes: #5310 

Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->

Co-authored-by: SW van Heerden <swvheerden@gmail.com>
  • Loading branch information
brianp and SWvheerden committed Apr 12, 2023
1 parent 30419cf commit 2f5d498
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion common/src/configuration/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,21 @@ impl Network {

/// The default network for all applications
impl Default for Network {
#[cfg(tari_network_mainnet)]
fn default() -> Self {
// TODO: set the default network to mainnet
Network::StageNet
}

#[cfg(tari_network_nextnet)]
fn default() -> Self {
Network::NextNet
}

#[cfg(all(not(tari_network_mainnet), not(tari_network_nextnet)))]
fn default() -> Self {
Network::Esmeralda
}
}

impl FromStr for Network {
Expand Down Expand Up @@ -195,7 +206,7 @@ mod test {
#[test]
fn network_default() {
let network = Network::default();
assert_eq!(network, Network::StageNet);
assert_eq!(network, Network::Esmeralda);
}

#[test]
Expand Down

0 comments on commit 2f5d498

Please sign in to comment.