Skip to content

Commit da5007e

Browse files
committed
Format.
1 parent 99f2cd4 commit da5007e

33 files changed

+1530
-869
lines changed

concordium-node/benches/p2p_lib_benchmark.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ macro_rules! bench_s11n {
1515
pub fn bench_s11n(c: &mut Criterion) {
1616
let mut group = c.benchmark_group($name);
1717

18-
for &size in &[256, 1024, 4096, 64 * 1024, 256 * 1024, 1024 * 1024, 4 * 1024 * 1024] {
18+
for &size in &[
19+
256,
20+
1024,
21+
4096,
22+
64 * 1024,
23+
256 * 1024,
24+
1024 * 1024,
25+
4 * 1024 * 1024,
26+
] {
1927
let msg = create_random_packet(size);
2028
let mut buffer = Cursor::new(Vec::with_capacity(size));
2129

@@ -86,7 +94,13 @@ mod dedup {
8694

8795
dedup_bench!(small_bench_dedup_xxhash64, XxHash64, "XxHash64", 8, 250);
8896
dedup_bench!(small_bench_dedup_sha256, Sha256, "SHA256", 32, 250);
89-
dedup_bench!(medium_bench_dedup_xxhash64, XxHash64, "XxHash64", 8, 1_048_576);
97+
dedup_bench!(
98+
medium_bench_dedup_xxhash64,
99+
XxHash64,
100+
"XxHash64",
101+
8,
102+
1_048_576
103+
);
90104
dedup_bench!(medium_bench_dedup_sha256, Sha256, "SHA256", 32, 1_048_576);
91105
dedup_bench!(big_bench_dedup_xxhash64, XxHash64, "XxHash64", 8, 4_194_304);
92106
dedup_bench!(big_bench_dedup_sha256, Sha256, "SHA256", 32, 4_194_304);

concordium-node/build.rs

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ const GHC_VARIANT: &str = "aarch64-osx";
1111

1212
#[cfg(not(feature = "static"))]
1313
fn command_output(cmd: &mut Command) -> String {
14-
str::from_utf8(&cmd.output().unwrap().stdout).unwrap().trim_end().to_string()
14+
str::from_utf8(&cmd.output().unwrap().stdout)
15+
.unwrap()
16+
.trim_end()
17+
.to_string()
1518
}
1619

1720
fn main() -> std::io::Result<()> {
1821
let cargo_dir = env!("CARGO_MANIFEST_DIR");
1922
// Compile the flatbuffers schema
20-
println!("cargo:rerun-if-changed={}/src/network/serialization/schema.fbs", cargo_dir);
23+
println!(
24+
"cargo:rerun-if-changed={}/src/network/serialization/schema.fbs",
25+
cargo_dir
26+
);
2127
flatc_rust::run(flatc_rust::Args {
2228
inputs: &[Path::new("src/network/serialization/schema.fbs")],
2329
out_dir: Path::new("target/"),
@@ -45,7 +51,10 @@ fn main() -> std::io::Result<()> {
4551
let stack_install_root = Path::new(&stack_install_root_command);
4652
let dll_location = stack_install_root.join("lib");
4753

48-
println!("cargo:rustc-link-search=native={}", dll_location.to_string_lossy());
54+
println!(
55+
"cargo:rustc-link-search=native={}",
56+
dll_location.to_string_lossy()
57+
);
4958
println!("cargo:rustc-link-lib=dylib=concordium-consensus");
5059
}
5160
#[cfg(not(windows))]
@@ -76,7 +85,10 @@ fn main() -> std::io::Result<()> {
7685
let stack_install_root = Path::new(&stack_install_root_command);
7786
let stack_install_lib = stack_install_root.join("lib");
7887

79-
println!("cargo:rustc-link-search={}", stack_install_lib.to_string_lossy());
88+
println!(
89+
"cargo:rustc-link-search={}",
90+
stack_install_lib.to_string_lossy()
91+
);
8092
println!("cargo:rustc-link-lib=dylib=concordium-consensus");
8193

8294
// Find the first subdirectory of <stack_install_lib> whose filename has
@@ -91,8 +103,9 @@ fn main() -> std::io::Result<()> {
91103
// `.DYLIB_EXTENSION` to the linked libraries list.
92104
for dir_entry in dir {
93105
let path = dir_entry?.path();
94-
if let Some(true) =
95-
path.extension().map(|ext| ext.to_string_lossy() == DYLIB_EXTENSION)
106+
if let Some(true) = path
107+
.extension()
108+
.map(|ext| ext.to_string_lossy() == DYLIB_EXTENSION)
96109
// FIXME: On a mac we should ignore case, but not on linux
97110
{
98111
let name = path
@@ -139,7 +152,10 @@ fn build_grpc2(proto_root_input: &str) -> std::io::Result<()> {
139152
{
140153
let types = format!("{}/v2/concordium/types.proto", proto_root_input);
141154
println!("cargo:rerun-if-changed={}", types);
142-
let plts = format!("{}/v2/concordium/protocol-level-tokens.proto", proto_root_input);
155+
let plts = format!(
156+
"{}/v2/concordium/protocol-level-tokens.proto",
157+
proto_root_input
158+
);
143159
println!("cargo:rerun-if-changed={}", plts);
144160
let kernel = format!("{}/v2/concordium/kernel.proto", proto_root_input);
145161
println!("cargo:rerun-if-changed={}", kernel);
@@ -763,7 +779,9 @@ fn build_grpc2(proto_root_input: &str) -> std::io::Result<()> {
763779
// Due to the slightly hacky nature of the RawCodec (i.e., it does not support
764780
// deserialization) we cannot build the client. But we also don't need it in the
765781
// node.
766-
tonic_build::manual::Builder::new().build_client(false).compile(&[query_service]);
782+
tonic_build::manual::Builder::new()
783+
.build_client(false)
784+
.compile(&[query_service]);
767785

768786
{
769787
let health = format!("{}/v2/concordium/health.proto", proto_root_input);
@@ -819,7 +837,10 @@ fn link_ghc_libs() -> std::io::Result<std::path::PathBuf> {
819837
]))
820838
});
821839
let rts_dir = ghc_variant(Path::new(&ghc_lib_dir))?;
822-
println!("cargo:rustc-link-search=native={}", rts_dir.to_string_lossy());
840+
println!(
841+
"cargo:rustc-link-search=native={}",
842+
rts_dir.to_string_lossy()
843+
);
823844
for item in std::fs::read_dir(&rts_dir)?.filter_map(Result::ok) {
824845
let path = item.path();
825846
let file_stem = path.file_stem().unwrap().to_string_lossy();
@@ -842,31 +863,36 @@ fn link_static_libs() -> std::io::Result<()> {
842863
#[cfg(feature = "profiling")]
843864
let path = format!("{}/deps/static-libs/linux/profiling", out_dir);
844865

845-
["concordium", "dependencies", "ghc"].iter().for_each(|subdir| {
846-
println!("cargo:rustc-link-search=native={}/{}", path, subdir);
847-
let walker = walkdir::WalkDir::new(Path::new(&format!("{}/{}", path, subdir)))
848-
.into_iter()
849-
.filter_map(Result::ok);
850-
for item in walker {
851-
match item.file_name().to_str() {
852-
Some(lib_file) => {
853-
// We link with all the libraries, but exclude the non-threaded Haskell RTS.
854-
if lib_file.starts_with("lib")
855-
&& lib_file.ends_with(".a")
856-
&& (!lib_file.starts_with("libHSrts") || lib_file.contains("_thr"))
857-
{
858-
println!(
859-
"cargo:rustc-link-lib=static={}",
860-
&lib_file[3..lib_file.len() - 2]
861-
);
866+
["concordium", "dependencies", "ghc"]
867+
.iter()
868+
.for_each(|subdir| {
869+
println!("cargo:rustc-link-search=native={}/{}", path, subdir);
870+
let walker = walkdir::WalkDir::new(Path::new(&format!("{}/{}", path, subdir)))
871+
.into_iter()
872+
.filter_map(Result::ok);
873+
for item in walker {
874+
match item.file_name().to_str() {
875+
Some(lib_file) => {
876+
// We link with all the libraries, but exclude the non-threaded Haskell RTS.
877+
if lib_file.starts_with("lib")
878+
&& lib_file.ends_with(".a")
879+
&& (!lib_file.starts_with("libHSrts") || lib_file.contains("_thr"))
880+
{
881+
println!(
882+
"cargo:rustc-link-lib=static={}",
883+
&lib_file[3..lib_file.len() - 2]
884+
);
885+
}
862886
}
887+
_ => panic!("Unable to link ghc libs"),
863888
}
864-
_ => panic!("Unable to link ghc libs"),
865889
}
866-
}
867-
});
890+
});
868891

869-
println!("cargo:rustc-link-search=native={}/deps/static-libs/linux/rust", out_dir);
892+
println!(
893+
"cargo:rustc-link-search=native={}/deps/static-libs/linux/rust",
894+
out_dir
895+
);
870896
println!("cargo:rustc-link-lib=static=Rcrypto");
871897
println!("cargo:rustc-link-lib=static=concordium_smart_contract_engine");
872898

@@ -895,7 +921,10 @@ fn ghc_variant(stack_install_lib: &Path) -> std::io::Result<std::path::PathBuf>
895921
match ghc_variant_dir {
896922
Some(path) => Ok(path),
897923
None => {
898-
eprintln!("No subdirectory in {:?} with prefix {}", stack_install_lib, GHC_VARIANT);
924+
eprintln!(
925+
"No subdirectory in {:?} with prefix {}",
926+
stack_install_lib, GHC_VARIANT
927+
);
899928
Err(std::io::Error::new(
900929
std::io::ErrorKind::NotFound,
901930
"GHC_VARIANT directory not found",

concordium-node/src/bin/bootstrap_checker.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ fn main() -> anyhow::Result<()> {
4141
"Bootstrapper can't run without specifying genesis hashes."
4242
);
4343

44-
let (node, server, poll) =
45-
P2PNode::new(conf.common.id, &conf, PeerType::Node, stats_export_service, regenesis_arc)
46-
.context("Failed to create the node.")?;
44+
let (node, server, poll) = P2PNode::new(
45+
conf.common.id,
46+
&conf,
47+
PeerType::Node,
48+
stats_export_service,
49+
regenesis_arc,
50+
)
51+
.context("Failed to create the node.")?;
4752

4853
spawn(&node, server, poll, None);
4954

concordium-node/src/bin/bootstrapper.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ async fn main() -> anyhow::Result<()> {
3131
.regenesis_block_hashes
3232
.clone()
3333
.unwrap_or_else(|| data_dir_path.join(std::path::Path::new("genesis_hash")));
34-
let regenesis_hashes_bytes = std::fs::read(&fname)
35-
.context(format!("Could not open file {} with genesis hashes.", fname.to_string_lossy()))?;
34+
let regenesis_hashes_bytes = std::fs::read(&fname).context(format!(
35+
"Could not open file {} with genesis hashes.",
36+
fname.to_string_lossy()
37+
))?;
3638
let regenesis_blocks: Vec<BlockHash> = serde_json::from_slice(&regenesis_hashes_bytes)
3739
.context("Could not parse genesis hashes.")?;
3840
let regenesis_arc: Arc<Regenesis> = Arc::new(Regenesis::from_blocks(regenesis_blocks));
@@ -58,13 +60,18 @@ async fn main() -> anyhow::Result<()> {
5860
let (sender, _) = tokio::sync::broadcast::channel(1);
5961
tokio::spawn(async move {
6062
stats_export_service
61-
.start_server(SocketAddr::new(conf.prometheus.prometheus_listen_addr, plp), sender)
63+
.start_server(
64+
SocketAddr::new(conf.prometheus.prometheus_listen_addr, plp),
65+
sender,
66+
)
6267
.await
6368
});
6469
}
6570

6671
// Set the startime in the stats.
67-
node.stats.node_startup_timestamp.set(node.start_time.timestamp_millis());
72+
node.stats
73+
.node_startup_timestamp
74+
.set(node.start_time.timestamp_millis());
6875

6976
spawn(&node, server, poll, None);
7077

0 commit comments

Comments
 (0)