This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Paitrault <[email protected]>
- Loading branch information
Showing
25 changed files
with
119 additions
and
168 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct ReliableBroadcastParams { | ||
/// Echo threshold | ||
pub echo_threshold: usize, | ||
/// Ready threshold | ||
pub ready_threshold: usize, | ||
/// Delivery threshold | ||
pub delivery_threshold: usize, | ||
} | ||
|
||
impl ReliableBroadcastParams { | ||
pub fn new(n: usize) -> Self { | ||
let f: usize = n / 3; | ||
|
||
Self { | ||
echo_threshold: 1 + (n + f) / 2, | ||
ready_threshold: 1 + f, | ||
delivery_threshold: 2 * f + 1, | ||
} | ||
} | ||
} |
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,64 @@ | ||
use std::net::SocketAddr; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use topos_p2p::Multiaddr; | ||
|
||
use super::DEFAULT_IP; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct P2PConfig { | ||
/// List of multiaddresses to listen for incoming connections | ||
#[serde(default = "default_listen_addresses")] | ||
pub listen_addresses: Vec<Multiaddr>, | ||
/// List of multiaddresses to advertise to the network | ||
#[serde(default = "default_public_addresses")] | ||
pub public_addresses: Vec<Multiaddr>, | ||
|
||
#[serde(skip)] | ||
pub is_bootnode: bool, | ||
} | ||
|
||
impl Default for P2PConfig { | ||
fn default() -> Self { | ||
Self { | ||
listen_addresses: default_listen_addresses(), | ||
public_addresses: default_public_addresses(), | ||
is_bootnode: false, | ||
} | ||
} | ||
} | ||
|
||
const fn default_libp2p_api_addr() -> SocketAddr { | ||
SocketAddr::V4(std::net::SocketAddrV4::new(DEFAULT_IP, 9090)) | ||
} | ||
|
||
fn default_listen_addresses() -> Vec<Multiaddr> { | ||
vec![format!( | ||
"/ip4/{}/tcp/{}", | ||
default_libp2p_api_addr().ip(), | ||
default_libp2p_api_addr().port() | ||
) | ||
.parse() | ||
.expect( | ||
r#" | ||
Listen multiaddresses generation failure. | ||
This is a critical bug that need to be report on `https://github.com/topos-protocol/topos/issues` | ||
"#, | ||
)] | ||
} | ||
|
||
fn default_public_addresses() -> Vec<Multiaddr> { | ||
vec![format!( | ||
"/ip4/{}/tcp/{}", | ||
default_libp2p_api_addr().ip(), | ||
default_libp2p_api_addr().port() | ||
) | ||
.parse() | ||
.expect( | ||
r#" | ||
Public multiaddresses generation failure. | ||
This is a critical bug that need to be report on `https://github.com/topos-protocol/topos/issues` | ||
"#, | ||
)] | ||
} |
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
Oops, something went wrong.