diff --git a/Cargo.lock b/Cargo.lock index 2855514f..86346e93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -643,6 +643,20 @@ dependencies = [ "serde", ] +[[package]] +name = "cuprated" +version = "0.1.0" +dependencies = [ + "bytes", + "cuprate-blockchain", + "cuprate-consensus", + "cuprate-p2p", + "dandelion-tower", + "futures", + "monero-p2p", + "tokio", +] + [[package]] name = "curve25519-dalek" version = "4.1.2" @@ -690,7 +704,7 @@ dependencies = [ ] [[package]] -name = "dandelion_tower" +name = "dandelion-tower" version = "0.1.0" dependencies = [ "futures", diff --git a/Cargo.toml b/Cargo.toml index c1ebaf20..4a8b7bd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ "storage/database", "pruning", "test-utils", - "types", + "types", "binaries/cuprated", ] [profile.release] diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml new file mode 100644 index 00000000..ba15745b --- /dev/null +++ b/binaries/cuprated/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "cuprated" +version = "0.1.0" +edition = "2021" +license = "AGPL-3-only" +authors = ["Boog900", "hinto-janai", "SyntheticBird45"] + +[dependencies] +# P2P +cuprate-p2p = { path = "../../p2p/cuprate-p2p" } +monero-p2p = { path = "../../p2p/monero-p2p" } +dandelion-tower = { path = "../../p2p/dandelion" } + +# Databases +cuprate-blockchain = { path = "../../storage/cuprate-blockchain" } + +# Consensus +cuprate-consensus = { path = "../../consensus" } + +# Async +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } +futures = { workspace = true } + +# Utils +bytes = { workspace = true } + diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs new file mode 100644 index 00000000..9397949e --- /dev/null +++ b/binaries/cuprated/src/main.rs @@ -0,0 +1,7 @@ +mod network; +mod p2p_request_handler; +mod syncer; + +fn main() { + println!("Hello, world!"); +} diff --git a/binaries/cuprated/src/network.rs b/binaries/cuprated/src/network.rs new file mode 100644 index 00000000..a4a25a28 --- /dev/null +++ b/binaries/cuprated/src/network.rs @@ -0,0 +1,26 @@ +use bytes::Bytes; +use dandelion_tower::TxState; +use futures::Stream; + +/// A trait representing the whole P2P network, including all network zones. +/// +/// [`cuprate_p2p`] provides a per [`NetworkZone`](monero_p2p::NetworkZone) abstraction in [`TODO`], this trait +/// provides a full abstraction, just exposing a minimal interface for Cuprate to interact with. +/// +/// It's methods will handle routing to the different [`NetworkZone`](monero_p2p::NetworkZone)s when required. +/// +/// This is kept generic for testing purposes. +trait P2PNetwork: Clone { + /// An identifier for a node on any [`NetworkZone`](monero_p2p::NetworkZone) + type PeerID; + /// The block downloader stream. + type BlockDownloader: Stream; + + /// Broadcasts a block to the network. + fn broadcast_block(&mut self, block_bytes: Bytes, chain_height: u64); + + /// Broadcasts a transaction to the network. + fn broadcast_transaction(&mut self, tx_bytes: Bytes, state: TxState); + + fn block_downloader(&mut self) -> Self::BlockDownloader; +} diff --git a/binaries/cuprated/src/p2p_request_handler.rs b/binaries/cuprated/src/p2p_request_handler.rs new file mode 100644 index 00000000..e69de29b diff --git a/binaries/cuprated/src/syncer.rs b/binaries/cuprated/src/syncer.rs new file mode 100644 index 00000000..7fc13dad --- /dev/null +++ b/binaries/cuprated/src/syncer.rs @@ -0,0 +1,4 @@ +//! # The Syncer +//! +//! The syncer is the part of Cuprate that handles keeping the blockchain state, it handles syncing if +//! we have fallen behind, and it handles incoming blocks. diff --git a/p2p/dandelion/Cargo.toml b/p2p/dandelion/Cargo.toml index a8a04691..e5d7e340 100644 --- a/p2p/dandelion/Cargo.toml +++ b/p2p/dandelion/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "dandelion_tower" +name = "dandelion-tower" version = "0.1.0" edition = "2021" license = "MIT"