Skip to content

Commit

Permalink
P2P layer for rusty-kaspa (#101)
Browse files Browse the repository at this point in the history
* P2P layer for rusty-kaspa
1. Server + Client side
2. Basic flow example

* Use ctrlc which supports windows os for termination signal and ignore non-working long test

* Fix new clippy uninlined-format-args lint

Co-authored-by: msutton <[email protected]>
  • Loading branch information
reshmem and michaelsutton authored Jan 27, 2023
1 parent 4b842e5 commit 8cdfff9
Show file tree
Hide file tree
Showing 14 changed files with 2,646 additions and 1 deletion.
142 changes: 141 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"rpc/core",
"rpc/grpc",
"mining",
"p2p",
]

[workspace.package]
Expand Down
37 changes: 37 additions & 0 deletions p2p/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "kaspa-p2p"
version.workspace = true
edition.workspace = true
authors.workspace = true
include.workspace = true
license.workspace = true

[lib]
name = "kaspa_p2p_lib"
path = "./src/lib.rs"

[[bin]]
name = "kaspa_p2p_client"
path = "./src/bin/p2p_client.rs"

[[bin]]
name = "kaspa_p2p_server"
path = "./src/bin/p2p_server.rs"

[dependencies]
# project internal deps
kaspa-core.workspace = true
log.workspace = true
# project external deps
futures = { version = "0.3", default-features = false, features = ["alloc"] }
prost = "0.11"
ctrlc = "3.2"
tokio = { version = "1.21.2", features = [ "rt-multi-thread", "macros", "signal" ]}
tokio-stream = { version = "0.1.11", features = ["net"] }
tonic = { version = "0.8.2", features = ["tls", "gzip"] }
h2 = "0.3"
lockfree = "0.5.1"
uuid = { version = "1.2.2", features = ["v4","fast-rng"] }

[build-dependencies]
tonic-build = { version = "0.8.2", features = ["prost"] }
14 changes: 14 additions & 0 deletions p2p/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fn main() {
let iface_files = &["messages.proto", "p2p.proto", "rpc.proto"];
let dirs = &["./proto"];

tonic_build::configure()
.build_server(true)
.build_client(true)
.compile(iface_files, dirs)
.unwrap_or_else(|e| panic!("protobuf compilation failed, error: {e}"));
// recompile protobufs only if any of the proto files changes.
for file in iface_files {
println!("cargo:rerun-if-changed={file}");
}
}
Loading

0 comments on commit 8cdfff9

Please sign in to comment.