mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
workspace: enforce crate/directory naming scheme (#164)
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
* rename all directories and crates * fix all `use` * fix doc link * `dandelion/` -> `dandelion-tower/` * fix epee-encoding test * fix `json-rpc` * fix pruning * crate import fixes * fix leftover merge conflicts * fix `epee-encoding`
This commit is contained in:
parent
519d871ccb
commit
4b93dbec4c
157 changed files with 434 additions and 410 deletions
304
Cargo.lock
generated
304
Cargo.lock
generated
|
@ -56,16 +56,6 @@ version = "1.0.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
|
||||
|
||||
[[package]]
|
||||
name = "async-buffer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"pin-project",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-lock"
|
||||
version = "3.4.0"
|
||||
|
@ -469,12 +459,32 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "cryptonight-cuprate"
|
||||
name = "cuprate-address-book"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"hex",
|
||||
"borsh",
|
||||
"cuprate-p2p-core",
|
||||
"cuprate-pruning",
|
||||
"cuprate-test-utils",
|
||||
"cuprate-wire",
|
||||
"futures",
|
||||
"indexmap 2.2.6",
|
||||
"rand",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-async-buffer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"pin-project",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -487,6 +497,7 @@ dependencies = [
|
|||
"cfg-if",
|
||||
"crossbeam",
|
||||
"cuprate-helper",
|
||||
"cuprate-pruning",
|
||||
"cuprate-test-utils",
|
||||
"cuprate-types",
|
||||
"curve25519-dalek",
|
||||
|
@ -494,7 +505,6 @@ dependencies = [
|
|||
"heed",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"monero-pruning",
|
||||
"monero-serai",
|
||||
"page_size",
|
||||
"paste",
|
||||
|
@ -542,7 +552,7 @@ name = "cuprate-consensus-rules"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"crypto-bigint",
|
||||
"cryptonight-cuprate",
|
||||
"cuprate-cryptonight",
|
||||
"cuprate-helper",
|
||||
"curve25519-dalek",
|
||||
"dalek-ff-group",
|
||||
|
@ -559,6 +569,46 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-cryptonight"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"hex",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-dandelion-tower"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"proptest",
|
||||
"rand",
|
||||
"rand_distr",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-database"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-epee-encoding"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"cuprate-fixed-bytes",
|
||||
"hex",
|
||||
"paste",
|
||||
"ref-cast",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-fast-sync"
|
||||
version = "0.1.0"
|
||||
|
@ -579,6 +629,14 @@ dependencies = [
|
|||
"tower",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-fixed-bytes"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-helper"
|
||||
version = "0.1.0"
|
||||
|
@ -594,24 +652,49 @@ dependencies = [
|
|||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-json-rpc"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"pretty_assertions",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-levin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"bytes",
|
||||
"futures",
|
||||
"proptest",
|
||||
"rand",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-p2p"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-buffer",
|
||||
"bytes",
|
||||
"cuprate-address-book",
|
||||
"cuprate-async-buffer",
|
||||
"cuprate-fixed-bytes",
|
||||
"cuprate-helper",
|
||||
"cuprate-p2p-core",
|
||||
"cuprate-pruning",
|
||||
"cuprate-test-utils",
|
||||
"cuprate-wire",
|
||||
"dashmap",
|
||||
"fixed-bytes",
|
||||
"futures",
|
||||
"hex",
|
||||
"indexmap 2.2.6",
|
||||
"monero-address-book",
|
||||
"monero-p2p",
|
||||
"monero-pruning",
|
||||
"monero-serai",
|
||||
"monero-wire",
|
||||
"pin-project",
|
||||
"proptest",
|
||||
"rand",
|
||||
|
@ -626,10 +709,43 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-p2p-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"borsh",
|
||||
"cuprate-helper",
|
||||
"cuprate-pruning",
|
||||
"cuprate-test-utils",
|
||||
"cuprate-wire",
|
||||
"futures",
|
||||
"hex",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-pruning"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"borsh",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-rpc-interface"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-rpc-types"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-test-utils"
|
||||
version = "0.1.0"
|
||||
|
@ -638,13 +754,13 @@ dependencies = [
|
|||
"borsh",
|
||||
"bytes",
|
||||
"cuprate-helper",
|
||||
"cuprate-p2p-core",
|
||||
"cuprate-types",
|
||||
"cuprate-wire",
|
||||
"futures",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"monero-p2p",
|
||||
"monero-serai",
|
||||
"monero-wire",
|
||||
"pretty_assertions",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -665,6 +781,19 @@ dependencies = [
|
|||
"monero-serai",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuprate-wire"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"bytes",
|
||||
"cuprate-epee-encoding",
|
||||
"cuprate-fixed-bytes",
|
||||
"cuprate-levin",
|
||||
"hex",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "4.1.3"
|
||||
|
@ -710,21 +839,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dandelion-tower"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"proptest",
|
||||
"rand",
|
||||
"rand_distr",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "5.5.3"
|
||||
|
@ -738,10 +852,6 @@ dependencies = [
|
|||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "database"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
|
@ -808,18 +918,6 @@ version = "1.12.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
|
||||
|
||||
[[package]]
|
||||
name = "epee-encoding"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fixed-bytes",
|
||||
"hex",
|
||||
"paste",
|
||||
"ref-cast",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
|
@ -880,14 +978,6 @@ version = "0.2.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
|
||||
|
||||
[[package]]
|
||||
name = "fixed-bytes"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flexible-transcript"
|
||||
version = "0.3.2"
|
||||
|
@ -1299,16 +1389,6 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json-rpc"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"pretty_assertions",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keccak"
|
||||
version = "0.1.5"
|
||||
|
@ -1324,21 +1404,6 @@ version = "1.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "levin-cuprate"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"bytes",
|
||||
"futures",
|
||||
"proptest",
|
||||
"rand",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.155"
|
||||
|
@ -1442,25 +1507,6 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-address-book"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"borsh",
|
||||
"cuprate-test-utils",
|
||||
"futures",
|
||||
"indexmap 2.2.6",
|
||||
"monero-p2p",
|
||||
"monero-pruning",
|
||||
"monero-wire",
|
||||
"rand",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-generators"
|
||||
version = "0.4.0"
|
||||
|
@ -1474,39 +1520,6 @@ dependencies = [
|
|||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-p2p"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"borsh",
|
||||
"cuprate-helper",
|
||||
"cuprate-test-utils",
|
||||
"futures",
|
||||
"hex",
|
||||
"monero-pruning",
|
||||
"monero-wire",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-pruning"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"borsh",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-rpc-types"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "monero-serai"
|
||||
version = "0.1.4-alpha"
|
||||
|
@ -1540,19 +1553,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-wire"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"bytes",
|
||||
"epee-encoding",
|
||||
"fixed-bytes",
|
||||
"hex",
|
||||
"levin-cuprate",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multiexp"
|
||||
version = "0.4.0"
|
||||
|
|
16
Cargo.toml
16
Cargo.toml
|
@ -10,21 +10,21 @@ members = [
|
|||
"net/epee-encoding",
|
||||
"net/fixed-bytes",
|
||||
"net/levin",
|
||||
"net/monero-wire",
|
||||
"p2p/cuprate-p2p",
|
||||
"p2p/dandelion",
|
||||
"p2p/monero-p2p",
|
||||
"net/wire",
|
||||
"p2p/p2p",
|
||||
"p2p/p2p-core",
|
||||
"p2p/dandelion-tower",
|
||||
"p2p/async-buffer",
|
||||
"p2p/address-book",
|
||||
"storage/cuprate-blockchain",
|
||||
"storage/cuprate-txpool",
|
||||
"storage/blockchain",
|
||||
"storage/txpool",
|
||||
"storage/database",
|
||||
"pruning",
|
||||
"test-utils",
|
||||
"types",
|
||||
"rpc/json-rpc",
|
||||
"rpc/monero-rpc-types",
|
||||
"rpc/cuprate-rpc-interface",
|
||||
"rpc/rpc-types",
|
||||
"rpc/rpc-interface",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
|
|
@ -10,7 +10,7 @@ path = "src/create.rs"
|
|||
|
||||
[dependencies]
|
||||
clap = { workspace = true, features = ["derive", "std"] }
|
||||
cuprate-blockchain = { path = "../../storage/cuprate-blockchain" }
|
||||
cuprate-blockchain = { path = "../../storage/blockchain" }
|
||||
cuprate-consensus = { path = ".." }
|
||||
cuprate-consensus-rules = { path = "../rules" }
|
||||
cuprate-types = { path = "../../types" }
|
||||
|
|
|
@ -12,7 +12,7 @@ rayon = ["dep:rayon"]
|
|||
|
||||
[dependencies]
|
||||
cuprate-helper = { path = "../../helper", default-features = false, features = ["std"] }
|
||||
cryptonight-cuprate = {path = "../../cryptonight"}
|
||||
cuprate-cryptonight = {path = "../../cryptonight"}
|
||||
|
||||
monero-serai = { workspace = true, features = ["std"] }
|
||||
multiexp = { workspace = true, features = ["std", "batch"] }
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::HashSet;
|
|||
use crypto_bigint::{CheckedMul, U256};
|
||||
use monero_serai::block::Block;
|
||||
|
||||
use cryptonight_cuprate::*;
|
||||
use cuprate_cryptonight::*;
|
||||
|
||||
use crate::{
|
||||
current_unix_timestamp,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "cryptonight-cuprate"
|
||||
name = "cuprate-cryptonight"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "A wrapper around Monero's CryptoNight hash function."
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "epee-encoding"
|
||||
name = "cuprate-epee-encoding"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
@ -12,10 +12,10 @@ rust-version = "1.60"
|
|||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["dep:thiserror", "bytes/std", "fixed-bytes/std"]
|
||||
std = ["dep:thiserror", "bytes/std", "cuprate-fixed-bytes/std"]
|
||||
|
||||
[dependencies]
|
||||
fixed-bytes = { path = "../fixed-bytes", default-features = false }
|
||||
cuprate-fixed-bytes = { path = "../fixed-bytes", default-features = false }
|
||||
|
||||
paste = "1.0.14"
|
||||
ref-cast = "1.0.22"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//!
|
||||
//! example without macro:
|
||||
//! ```rust
|
||||
//! # use epee_encoding::{EpeeObject, EpeeObjectBuilder, read_epee_value, write_field, to_bytes, from_bytes};
|
||||
//! # use cuprate_epee_encoding::{EpeeObject, EpeeObjectBuilder, read_epee_value, write_field, to_bytes, from_bytes};
|
||||
//! # use bytes::{Buf, BufMut};
|
||||
//!
|
||||
//! pub struct Test {
|
||||
|
@ -21,7 +21,7 @@
|
|||
//! }
|
||||
//!
|
||||
//! impl EpeeObjectBuilder<Test> for __TestEpeeBuilder {
|
||||
//! fn add_field<B: Buf>(&mut self, name: &str, r: &mut B) -> epee_encoding::error::Result<bool> {
|
||||
//! fn add_field<B: Buf>(&mut self, name: &str, r: &mut B) -> cuprate_epee_encoding::error::Result<bool> {
|
||||
//! match name {
|
||||
//! "val" => {self.val = Some(read_epee_value(r)?);}
|
||||
//! _ => return Ok(false),
|
||||
|
@ -29,10 +29,10 @@
|
|||
//! Ok(true)
|
||||
//! }
|
||||
//!
|
||||
//! fn finish(self) -> epee_encoding::error::Result<Test> {
|
||||
//! fn finish(self) -> cuprate_epee_encoding::error::Result<Test> {
|
||||
//! Ok(
|
||||
//! Test {
|
||||
//! val: self.val.ok_or_else(|| epee_encoding::error::Error::Format("Required field was not found!"))?
|
||||
//! val: self.val.ok_or_else(|| cuprate_epee_encoding::error::Error::Format("Required field was not found!"))?
|
||||
//! }
|
||||
//! )
|
||||
//! }
|
||||
|
@ -45,7 +45,7 @@
|
|||
//! 1
|
||||
//! }
|
||||
//!
|
||||
//! fn write_fields<B: BufMut>(self, w: &mut B) -> epee_encoding::error::Result<()> {
|
||||
//! fn write_fields<B: BufMut>(self, w: &mut B) -> cuprate_epee_encoding::error::Result<()> {
|
||||
//! // write the fields
|
||||
//! write_field(self.val, "val", w)
|
||||
//! }
|
||||
|
@ -233,7 +233,7 @@ fn write_epee_value<T: EpeeValue, B: BufMut>(val: T, w: &mut B) -> Result<()> {
|
|||
/// let t: [u8; 8] = [3, 0, 0, 0, 1, 0, 0, 0];
|
||||
/// let mut w = vec![];
|
||||
///
|
||||
/// epee_encoding::write_bytes(t, &mut w).unwrap();
|
||||
/// cuprate_epee_encoding::write_bytes(t, &mut w).unwrap();
|
||||
///
|
||||
/// assert_eq!(w.len(), 9); // length of bytes + bytes
|
||||
/// assert_eq!(w[1..], t);
|
||||
|
@ -274,7 +274,7 @@ pub fn write_bytes<T: AsRef<[u8]>, B: BufMut>(t: T, w: &mut B) -> Result<()> {
|
|||
/// let mut w = vec![];
|
||||
///
|
||||
/// let iter: std::vec::IntoIter<u64> = vec.into_iter();
|
||||
/// epee_encoding::write_iterator(iter, &mut w).unwrap();
|
||||
/// cuprate_epee_encoding::write_iterator(iter, &mut w).unwrap();
|
||||
///
|
||||
/// assert_eq!(w.len(), 17);
|
||||
/// assert_eq!(w[1..9], [3, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
|
|
@ -10,7 +10,7 @@ pub use paste::paste;
|
|||
/// // see: <https://github.com/rust-lang/rust/issues/64079>
|
||||
/// mod visibility {
|
||||
///
|
||||
/// use epee_encoding::epee_object;
|
||||
/// use cuprate_epee_encoding::epee_object;
|
||||
///
|
||||
/// struct Example {
|
||||
/// a: u8
|
||||
|
@ -30,7 +30,7 @@ pub use paste::paste;
|
|||
/// // see: <https://github.com/rust-lang/rust/issues/64079>
|
||||
/// mod visibility {
|
||||
///
|
||||
/// use epee_encoding::epee_object;
|
||||
/// use cuprate_epee_encoding::epee_object;
|
||||
///
|
||||
/// struct Example {
|
||||
/// a: u8,
|
||||
|
@ -60,7 +60,7 @@ pub use paste::paste;
|
|||
/// c: u8 as u8,
|
||||
/// // `=> read_fn, write_fn, should_write_fn,` allows you to specify alt field encoding functions.
|
||||
/// // for the required args see the default functions, which are used here:
|
||||
/// d: u8 => epee_encoding::read_epee_value, epee_encoding::write_field, <u8 as epee_encoding::EpeeValue>::should_write,
|
||||
/// d: u8 => cuprate_epee_encoding::read_epee_value, cuprate_epee_encoding::write_field, <u8 as cuprate_epee_encoding::EpeeValue>::should_write,
|
||||
/// // `!flatten` can be used on fields which are epee objects, and it flattens the fields of that object into this object.
|
||||
/// // So for this example `e_f` will not appear in the data but e will.
|
||||
/// // You can't use the other options with this.
|
||||
|
@ -126,25 +126,25 @@ macro_rules! epee_object {
|
|||
$(!flatten: $flat_field: ident: $flat_ty:ty ,)*
|
||||
|
||||
) => {
|
||||
epee_encoding::macros::paste!(
|
||||
cuprate_epee_encoding::macros::paste!(
|
||||
#[allow(non_snake_case)]
|
||||
mod [<__epee_builder_ $obj>] {
|
||||
use super::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct [<__Builder $obj>] {
|
||||
$($field: Option<epee_encoding::epee_object!(@internal_field_type $ty, $($ty_as)?)>,)*
|
||||
$($flat_field: <$flat_ty as epee_encoding::EpeeObject>::Builder,)*
|
||||
$($field: Option<cuprate_epee_encoding::epee_object!(@internal_field_type $ty, $($ty_as)?)>,)*
|
||||
$($flat_field: <$flat_ty as cuprate_epee_encoding::EpeeObject>::Builder,)*
|
||||
}
|
||||
|
||||
impl epee_encoding::EpeeObjectBuilder<$obj> for [<__Builder $obj>] {
|
||||
fn add_field<B: epee_encoding::macros::bytes::Buf>(&mut self, name: &str, b: &mut B) -> epee_encoding::error::Result<bool> {
|
||||
impl cuprate_epee_encoding::EpeeObjectBuilder<$obj> for [<__Builder $obj>] {
|
||||
fn add_field<B: cuprate_epee_encoding::macros::bytes::Buf>(&mut self, name: &str, b: &mut B) -> cuprate_epee_encoding::error::Result<bool> {
|
||||
match name {
|
||||
$(epee_encoding::epee_object!(@internal_field_name $field, $($alt_name)?) => {
|
||||
$(cuprate_epee_encoding::epee_object!(@internal_field_name $field, $($alt_name)?) => {
|
||||
if core::mem::replace(&mut self.$field, Some(
|
||||
epee_encoding::epee_object!(@internal_try_right_then_left epee_encoding::read_epee_value(b)?, $($read_fn(b)?)?)
|
||||
cuprate_epee_encoding::epee_object!(@internal_try_right_then_left cuprate_epee_encoding::read_epee_value(b)?, $($read_fn(b)?)?)
|
||||
)).is_some() {
|
||||
Err(epee_encoding::error::Error::Value(format!("Duplicate field in data: {}", epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?))))?;
|
||||
Err(cuprate_epee_encoding::error::Error::Value(format!("Duplicate field in data: {}", cuprate_epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?))))?;
|
||||
}
|
||||
Ok(true)
|
||||
},)*
|
||||
|
@ -159,12 +159,12 @@ macro_rules! epee_object {
|
|||
}
|
||||
}
|
||||
|
||||
fn finish(self) -> epee_encoding::error::Result<$obj> {
|
||||
fn finish(self) -> cuprate_epee_encoding::error::Result<$obj> {
|
||||
Ok(
|
||||
$obj {
|
||||
$(
|
||||
$field: {
|
||||
let epee_default_value = epee_encoding::epee_object!(@internal_try_right_then_left epee_encoding::EpeeValue::epee_default_value(), $({
|
||||
let epee_default_value = cuprate_epee_encoding::epee_object!(@internal_try_right_then_left cuprate_epee_encoding::EpeeValue::epee_default_value(), $({
|
||||
let _ = $should_write_fn;
|
||||
None
|
||||
})?);
|
||||
|
@ -173,7 +173,7 @@ macro_rules! epee_object {
|
|||
$(.or(Some($default)))?
|
||||
.or(epee_default_value)
|
||||
$(.map(<$ty_as>::into))?
|
||||
.ok_or(epee_encoding::error::Error::Value(format!("Missing field in data: {}", epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?))))?
|
||||
.ok_or(cuprate_epee_encoding::error::Error::Value(format!("Missing field in data: {}", cuprate_epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?))))?
|
||||
},
|
||||
)*
|
||||
|
||||
|
@ -187,16 +187,16 @@ macro_rules! epee_object {
|
|||
}
|
||||
}
|
||||
|
||||
impl epee_encoding::EpeeObject for $obj {
|
||||
impl cuprate_epee_encoding::EpeeObject for $obj {
|
||||
type Builder = [<__epee_builder_ $obj>]::[<__Builder $obj>];
|
||||
|
||||
fn number_of_fields(&self) -> u64 {
|
||||
let mut fields = 0;
|
||||
|
||||
$(
|
||||
let field = epee_encoding::epee_object!(@internal_try_right_then_left &self.$field, $(<&$ty_as>::from(&self.$field))? );
|
||||
let field = cuprate_epee_encoding::epee_object!(@internal_try_right_then_left &self.$field, $(<&$ty_as>::from(&self.$field))? );
|
||||
|
||||
if $((field) != &$default &&)? epee_encoding::epee_object!(@internal_try_right_then_left epee_encoding::EpeeValue::should_write, $($should_write_fn)?)(field )
|
||||
if $((field) != &$default &&)? cuprate_epee_encoding::epee_object!(@internal_try_right_then_left cuprate_epee_encoding::EpeeValue::should_write, $($should_write_fn)?)(field )
|
||||
{
|
||||
fields += 1;
|
||||
}
|
||||
|
@ -209,13 +209,13 @@ macro_rules! epee_object {
|
|||
fields
|
||||
}
|
||||
|
||||
fn write_fields<B: epee_encoding::macros::bytes::BufMut>(self, w: &mut B) -> epee_encoding::error::Result<()> {
|
||||
fn write_fields<B: cuprate_epee_encoding::macros::bytes::BufMut>(self, w: &mut B) -> cuprate_epee_encoding::error::Result<()> {
|
||||
$(
|
||||
let field = epee_encoding::epee_object!(@internal_try_right_then_left self.$field, $(<$ty_as>::from(self.$field))? );
|
||||
let field = cuprate_epee_encoding::epee_object!(@internal_try_right_then_left self.$field, $(<$ty_as>::from(self.$field))? );
|
||||
|
||||
if $(field != $default &&)? epee_encoding::epee_object!(@internal_try_right_then_left epee_encoding::EpeeValue::should_write, $($should_write_fn)?)(&field )
|
||||
if $(field != $default &&)? cuprate_epee_encoding::epee_object!(@internal_try_right_then_left cuprate_epee_encoding::EpeeValue::should_write, $($should_write_fn)?)(&field )
|
||||
{
|
||||
epee_encoding::epee_object!(@internal_try_right_then_left epee_encoding::write_field, $($write_fn)?)((field), epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?), w)?;
|
||||
cuprate_epee_encoding::epee_object!(@internal_try_right_then_left cuprate_epee_encoding::write_field, $($write_fn)?)((field), cuprate_epee_encoding::epee_object!(@internal_field_name$field, $($alt_name)?), w)?;
|
||||
}
|
||||
)*
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use core::fmt::Debug;
|
|||
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
|
||||
use fixed_bytes::{ByteArray, ByteArrayVec};
|
||||
use cuprate_fixed_bytes::{ByteArray, ByteArrayVec};
|
||||
|
||||
use crate::{
|
||||
io::{checked_read_primitive, checked_write_primitive},
|
||||
|
|
|
@ -10,7 +10,7 @@ const FITS_IN_FOUR_BYTES: u64 = 2_u64.pow(32 - SIZE_OF_SIZE_MARKER) - 1;
|
|||
/// Read an epee variable sized number from `r`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use epee_encoding::read_varint;
|
||||
/// use cuprate_epee_encoding::read_varint;
|
||||
///
|
||||
/// assert_eq!(read_varint(&mut [252].as_slice()).unwrap(), 63);
|
||||
/// assert_eq!(read_varint(&mut [1, 1].as_slice()).unwrap(), 64);
|
||||
|
@ -41,7 +41,7 @@ pub fn read_varint<B: Buf>(r: &mut B) -> Result<u64> {
|
|||
/// Write an epee variable sized number into `w`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use epee_encoding::write_varint;
|
||||
/// use cuprate_epee_encoding::write_varint;
|
||||
///
|
||||
/// let mut buf = vec![];
|
||||
///
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
|
||||
struct AltName {
|
||||
val: u8,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes};
|
||||
|
||||
struct T {
|
||||
a: u8,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
|
||||
pub struct Optional {
|
||||
val: u8,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
|
||||
struct Child {
|
||||
val: u64,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SupportFlags(u32);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes, to_bytes};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct BaseResponse {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes};
|
||||
|
||||
struct ObjSeq {
|
||||
seq: Vec<ObjSeq>,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use epee_encoding::{epee_object, from_bytes};
|
||||
use cuprate_epee_encoding::{epee_object, from_bytes};
|
||||
|
||||
struct D {
|
||||
val: u8,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "fixed-bytes"
|
||||
name = "cuprate-fixed-bytes"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "levin-cuprate"
|
||||
name = "cuprate-levin"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "A crate for working with the Levin protocol in Rust."
|
||||
|
|
|
@ -8,7 +8,7 @@ use tokio::{
|
|||
};
|
||||
use tokio_util::codec::{FramedRead, FramedWrite};
|
||||
|
||||
use levin_cuprate::{
|
||||
use cuprate_levin::{
|
||||
message::make_fragmented_messages, BucketBuilder, BucketError, LevinBody, LevinCommand,
|
||||
LevinMessageCodec, MessageType, Protocol,
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "monero-wire"
|
||||
name = "cuprate-wire"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
@ -8,12 +8,12 @@ repository = "https://github.com/SyntheticBird45/cuprate/tree/main/net/monero-wi
|
|||
|
||||
[features]
|
||||
default = []
|
||||
tracing = ["levin-cuprate/tracing"]
|
||||
tracing = ["cuprate-levin/tracing"]
|
||||
|
||||
[dependencies]
|
||||
levin-cuprate = {path="../levin"}
|
||||
epee-encoding = { path = "../epee-encoding" }
|
||||
fixed-bytes = { path = "../fixed-bytes" }
|
||||
cuprate-levin = { path = "../levin" }
|
||||
cuprate-epee-encoding = { path = "../epee-encoding" }
|
||||
cuprate-fixed-bytes = { path = "../fixed-bytes" }
|
||||
|
||||
bitflags = { workspace = true, features = ["std"] }
|
||||
bytes = { workspace = true, features = ["std"] }
|
|
@ -25,11 +25,11 @@
|
|||
pub mod network_address;
|
||||
pub mod p2p;
|
||||
|
||||
pub use levin_cuprate::BucketError;
|
||||
pub use cuprate_levin::BucketError;
|
||||
pub use network_address::{NetZone, NetworkAddress};
|
||||
pub use p2p::*;
|
||||
|
||||
// re-export.
|
||||
pub use levin_cuprate as levin;
|
||||
pub use cuprate_levin as levin;
|
||||
|
||||
pub type MoneroWireCodec = levin_cuprate::codec::LevinMessageCodec<Message>;
|
||||
pub type MoneroWireCodec = cuprate_levin::codec::LevinMessageCodec<Message>;
|
|
@ -18,7 +18,7 @@
|
|||
//! I2p. Currently this module only has IPv(4/6).
|
||||
//!
|
||||
use bytes::BufMut;
|
||||
use epee_encoding::EpeeObject;
|
||||
use cuprate_epee_encoding::EpeeObject;
|
||||
use std::{hash::Hash, net, net::SocketAddr};
|
||||
|
||||
mod epee_builder;
|
||||
|
@ -45,7 +45,7 @@ impl EpeeObject for NetworkAddress {
|
|||
2
|
||||
}
|
||||
|
||||
fn write_fields<B: BufMut>(self, w: &mut B) -> epee_encoding::Result<()> {
|
||||
fn write_fields<B: BufMut>(self, w: &mut B) -> cuprate_epee_encoding::Result<()> {
|
||||
TaggedNetworkAddress::from(self).write_fields(w)
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
use bytes::Buf;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
|
||||
use epee_encoding::{epee_object, EpeeObjectBuilder};
|
||||
use cuprate_epee_encoding::{epee_object, EpeeObjectBuilder};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::NetworkAddress;
|
||||
|
@ -19,19 +19,28 @@ epee_object!(
|
|||
);
|
||||
|
||||
impl EpeeObjectBuilder<NetworkAddress> for TaggedNetworkAddress {
|
||||
fn add_field<B: Buf>(&mut self, name: &str, b: &mut B) -> epee_encoding::Result<bool> {
|
||||
fn add_field<B: Buf>(&mut self, name: &str, b: &mut B) -> cuprate_epee_encoding::Result<bool> {
|
||||
match name {
|
||||
"type" => {
|
||||
if std::mem::replace(&mut self.ty, Some(epee_encoding::read_epee_value(b)?))
|
||||
.is_some()
|
||||
if std::mem::replace(
|
||||
&mut self.ty,
|
||||
Some(cuprate_epee_encoding::read_epee_value(b)?),
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
return Err(epee_encoding::Error::Format("Duplicate field in data."));
|
||||
return Err(cuprate_epee_encoding::Error::Format(
|
||||
"Duplicate field in data.",
|
||||
));
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
"addr" => {
|
||||
if std::mem::replace(&mut self.addr, epee_encoding::read_epee_value(b)?).is_some() {
|
||||
return Err(epee_encoding::Error::Format("Duplicate field in data."));
|
||||
if std::mem::replace(&mut self.addr, cuprate_epee_encoding::read_epee_value(b)?)
|
||||
.is_some()
|
||||
{
|
||||
return Err(cuprate_epee_encoding::Error::Format(
|
||||
"Duplicate field in data.",
|
||||
));
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
@ -39,9 +48,9 @@ impl EpeeObjectBuilder<NetworkAddress> for TaggedNetworkAddress {
|
|||
}
|
||||
}
|
||||
|
||||
fn finish(self) -> epee_encoding::Result<NetworkAddress> {
|
||||
fn finish(self) -> cuprate_epee_encoding::Result<NetworkAddress> {
|
||||
self.try_into()
|
||||
.map_err(|_| epee_encoding::Error::Value("Invalid network address".to_string()))
|
||||
.map_err(|_| cuprate_epee_encoding::Error::Value("Invalid network address".to_string()))
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,8 @@ use std::fmt::Formatter;
|
|||
|
||||
use bytes::{Buf, BytesMut};
|
||||
|
||||
use epee_encoding::epee_object;
|
||||
use levin_cuprate::{
|
||||
use cuprate_epee_encoding::epee_object;
|
||||
use cuprate_levin::{
|
||||
BucketBuilder, BucketError, LevinBody, LevinCommand as LevinCommandTrait, MessageType,
|
||||
};
|
||||
|
||||
|
@ -154,22 +154,23 @@ impl From<LevinCommand> for u32 {
|
|||
}
|
||||
}
|
||||
|
||||
fn decode_message<B: Buf, T: epee_encoding::EpeeObject, Ret>(
|
||||
fn decode_message<B: Buf, T: cuprate_epee_encoding::EpeeObject, Ret>(
|
||||
ret: impl FnOnce(T) -> Ret,
|
||||
buf: &mut B,
|
||||
) -> Result<Ret, BucketError> {
|
||||
let t = epee_encoding::from_bytes(buf).map_err(|e| BucketError::BodyDecodingError(e.into()))?;
|
||||
let t = cuprate_epee_encoding::from_bytes(buf)
|
||||
.map_err(|e| BucketError::BodyDecodingError(e.into()))?;
|
||||
Ok(ret(t))
|
||||
}
|
||||
|
||||
fn build_message<T: epee_encoding::EpeeObject>(
|
||||
fn build_message<T: cuprate_epee_encoding::EpeeObject>(
|
||||
id: LevinCommand,
|
||||
val: T,
|
||||
builder: &mut BucketBuilder<LevinCommand>,
|
||||
) -> Result<(), BucketError> {
|
||||
builder.set_command(id);
|
||||
builder.set_body(
|
||||
epee_encoding::to_bytes(val)
|
||||
cuprate_epee_encoding::to_bytes(val)
|
||||
.map(BytesMut::freeze)
|
||||
.map_err(|e| BucketError::BodyDecodingError(e.into()))?,
|
||||
);
|
||||
|
@ -280,13 +281,13 @@ impl RequestMessage {
|
|||
C::Handshake => decode_message(RequestMessage::Handshake, buf)?,
|
||||
C::TimedSync => decode_message(RequestMessage::TimedSync, buf)?,
|
||||
C::Ping => {
|
||||
epee_encoding::from_bytes::<EmptyMessage, _>(buf)
|
||||
cuprate_epee_encoding::from_bytes::<EmptyMessage, _>(buf)
|
||||
.map_err(|e| BucketError::BodyDecodingError(e.into()))?;
|
||||
|
||||
RequestMessage::Ping
|
||||
}
|
||||
C::SupportFlags => {
|
||||
epee_encoding::from_bytes::<EmptyMessage, _>(buf)
|
||||
cuprate_epee_encoding::from_bytes::<EmptyMessage, _>(buf)
|
||||
.map_err(|e| BucketError::BodyDecodingError(e.into()))?;
|
||||
|
||||
RequestMessage::SupportFlags
|
|
@ -19,7 +19,7 @@
|
|||
//! protocol messages.
|
||||
|
||||
use bytes::Bytes;
|
||||
use epee_encoding::epee_object;
|
||||
use cuprate_epee_encoding::epee_object;
|
||||
|
||||
use super::common::{BasicNodeData, CoreSyncData, PeerListEntryBase, PeerSupportFlags};
|
||||
|
||||
|
@ -134,7 +134,8 @@ mod tests {
|
|||
186, 15, 178, 70, 173, 170, 187, 31, 70, 50, 227, 11, 116, 111, 112, 95, 118, 101, 114,
|
||||
115, 105, 111, 110, 8, 1,
|
||||
];
|
||||
let handshake: HandshakeRequest = epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
let handshake: HandshakeRequest =
|
||||
cuprate_epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
let basic_node_data = BasicNodeData {
|
||||
my_port: 0,
|
||||
network_id: [
|
||||
|
@ -161,8 +162,9 @@ mod tests {
|
|||
assert_eq!(basic_node_data, handshake.node_data);
|
||||
assert_eq!(core_sync_data, handshake.payload_data);
|
||||
|
||||
let mut encoded_bytes = epee_encoding::to_bytes(handshake.clone()).unwrap();
|
||||
let handshake_2: HandshakeRequest = epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
let mut encoded_bytes = cuprate_epee_encoding::to_bytes(handshake.clone()).unwrap();
|
||||
let handshake_2: HandshakeRequest =
|
||||
cuprate_epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
|
||||
assert_eq!(handshake, handshake_2);
|
||||
}
|
||||
|
@ -938,7 +940,8 @@ mod tests {
|
|||
181, 216, 193, 135, 23, 186, 168, 207, 119, 86, 235, 11, 116, 111, 112, 95, 118, 101,
|
||||
114, 115, 105, 111, 110, 8, 16,
|
||||
];
|
||||
let handshake: HandshakeResponse = epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
let handshake: HandshakeResponse =
|
||||
cuprate_epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
|
||||
let basic_node_data = BasicNodeData {
|
||||
my_port: 18080,
|
||||
|
@ -967,9 +970,10 @@ mod tests {
|
|||
assert_eq!(core_sync_data, handshake.payload_data);
|
||||
assert_eq!(250, handshake.local_peerlist_new.len());
|
||||
|
||||
let mut encoded_bytes = epee_encoding::to_bytes(handshake.clone()).unwrap();
|
||||
let mut encoded_bytes = cuprate_epee_encoding::to_bytes(handshake.clone()).unwrap();
|
||||
|
||||
let handshake_2: HandshakeResponse = epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
let handshake_2: HandshakeResponse =
|
||||
cuprate_epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
|
||||
assert_eq!(handshake, handshake_2);
|
||||
}
|
|
@ -18,8 +18,8 @@
|
|||
use bitflags::bitflags;
|
||||
use bytes::{Buf, BufMut, Bytes};
|
||||
|
||||
use epee_encoding::{epee_object, EpeeValue, InnerMarker};
|
||||
use fixed_bytes::ByteArray;
|
||||
use cuprate_epee_encoding::{epee_object, EpeeValue, InnerMarker};
|
||||
use cuprate_fixed_bytes::ByteArray;
|
||||
|
||||
use crate::NetworkAddress;
|
||||
|
||||
|
@ -241,12 +241,12 @@ epee_object!(
|
|||
txs: TransactionBlobs = TransactionBlobs::None => tx_blob_read, tx_blob_write, should_write_tx_blobs,
|
||||
);
|
||||
|
||||
fn tx_blob_read<B: Buf>(b: &mut B) -> epee_encoding::Result<TransactionBlobs> {
|
||||
let marker = epee_encoding::read_marker(b)?;
|
||||
fn tx_blob_read<B: Buf>(b: &mut B) -> cuprate_epee_encoding::Result<TransactionBlobs> {
|
||||
let marker = cuprate_epee_encoding::read_marker(b)?;
|
||||
match marker.inner_marker {
|
||||
InnerMarker::Object => Ok(TransactionBlobs::Pruned(Vec::read(b, &marker)?)),
|
||||
InnerMarker::String => Ok(TransactionBlobs::Normal(Vec::read(b, &marker)?)),
|
||||
_ => Err(epee_encoding::Error::Value(
|
||||
_ => Err(cuprate_epee_encoding::Error::Value(
|
||||
"Invalid marker for tx blobs".to_string(),
|
||||
)),
|
||||
}
|
||||
|
@ -256,11 +256,15 @@ fn tx_blob_write<B: BufMut>(
|
|||
val: TransactionBlobs,
|
||||
field_name: &str,
|
||||
w: &mut B,
|
||||
) -> epee_encoding::Result<()> {
|
||||
) -> cuprate_epee_encoding::Result<()> {
|
||||
if should_write_tx_blobs(&val) {
|
||||
match val {
|
||||
TransactionBlobs::Normal(bytes) => epee_encoding::write_field(bytes, field_name, w)?,
|
||||
TransactionBlobs::Pruned(obj) => epee_encoding::write_field(obj, field_name, w)?,
|
||||
TransactionBlobs::Normal(bytes) => {
|
||||
cuprate_epee_encoding::write_field(bytes, field_name, w)?
|
||||
}
|
||||
TransactionBlobs::Pruned(obj) => {
|
||||
cuprate_epee_encoding::write_field(obj, field_name, w)?
|
||||
}
|
||||
TransactionBlobs::None => (),
|
||||
}
|
||||
}
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
use bytes::Bytes;
|
||||
|
||||
use epee_encoding::{container_as_blob::ContainerAsBlob, epee_object};
|
||||
use fixed_bytes::{ByteArray, ByteArrayVec};
|
||||
use cuprate_epee_encoding::{container_as_blob::ContainerAsBlob, epee_object};
|
||||
use cuprate_fixed_bytes::{ByteArray, ByteArrayVec};
|
||||
|
||||
use super::common::BlockCompleteEntry;
|
||||
|
||||
|
@ -705,13 +705,14 @@ mod tests {
|
|||
248, 248, 91, 110, 107, 144, 12, 175, 253, 21, 121, 28,
|
||||
];
|
||||
|
||||
let new_transactions: NewTransactions = epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
let new_transactions: NewTransactions =
|
||||
cuprate_epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
|
||||
assert_eq!(4, new_transactions.txs.len());
|
||||
|
||||
let mut encoded_bytes = epee_encoding::to_bytes(new_transactions.clone()).unwrap();
|
||||
let mut encoded_bytes = cuprate_epee_encoding::to_bytes(new_transactions.clone()).unwrap();
|
||||
let new_transactions_2: NewTransactions =
|
||||
epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
cuprate_epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
|
||||
assert_eq!(new_transactions, new_transactions_2);
|
||||
}
|
||||
|
@ -1057,10 +1058,12 @@ mod tests {
|
|||
101, 110, 116, 95, 98, 108, 111, 99, 107, 99, 104, 97, 105, 110, 95, 104, 101, 105,
|
||||
103, 104, 116, 5, 209, 45, 42, 0, 0, 0, 0, 0,
|
||||
];
|
||||
let fluffy_block: NewFluffyBlock = epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
let fluffy_block: NewFluffyBlock =
|
||||
cuprate_epee_encoding::from_bytes(&mut &bytes[..]).unwrap();
|
||||
|
||||
let mut encoded_bytes = epee_encoding::to_bytes(fluffy_block.clone()).unwrap();
|
||||
let fluffy_block_2: NewFluffyBlock = epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
let mut encoded_bytes = cuprate_epee_encoding::to_bytes(fluffy_block.clone()).unwrap();
|
||||
let fluffy_block_2: NewFluffyBlock =
|
||||
cuprate_epee_encoding::from_bytes(&mut encoded_bytes).unwrap();
|
||||
|
||||
assert_eq!(fluffy_block, fluffy_block_2);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "monero-address-book"
|
||||
name = "cuprate-address-book"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
@ -7,9 +7,9 @@ authors = ["Boog900"]
|
|||
|
||||
|
||||
[dependencies]
|
||||
monero-pruning = { path = "../../pruning" }
|
||||
monero-wire = { path= "../../net/monero-wire" }
|
||||
monero-p2p = { path = "../monero-p2p" }
|
||||
cuprate-pruning = { path = "../../pruning" }
|
||||
cuprate-wire = { path= "../../net/wire" }
|
||||
cuprate-p2p-core = { path = "../p2p-core" }
|
||||
|
||||
tower = { workspace = true, features = ["util"] }
|
||||
tokio = { workspace = true, features = ["time", "fs", "rt"]}
|
||||
|
|
|
@ -19,13 +19,13 @@ use tokio::{
|
|||
use tokio_util::time::DelayQueue;
|
||||
use tower::Service;
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::InternalPeerID,
|
||||
handles::ConnectionHandle,
|
||||
services::{AddressBookRequest, AddressBookResponse, ZoneSpecificPeerListEntryBase},
|
||||
NetZoneAddress, NetworkZone,
|
||||
};
|
||||
use monero_pruning::PruningSeed;
|
||||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
use crate::{peer_list::PeerList, store::save_peers_to_disk, AddressBookConfig, AddressBookError};
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ use std::{path::PathBuf, sync::Arc, time::Duration};
|
|||
use futures::StreamExt;
|
||||
use tokio::{sync::Semaphore, time::interval};
|
||||
|
||||
use monero_p2p::handles::HandleBuilder;
|
||||
use monero_pruning::PruningSeed;
|
||||
use cuprate_p2p_core::handles::HandleBuilder;
|
||||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
use super::{AddressBook, ConnectionPeerEntry, InternalPeerID};
|
||||
use crate::{peer_list::tests::make_fake_peer_list, AddressBookConfig, AddressBookError};
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
//!
|
||||
//! This module holds the logic for persistent peer storage.
|
||||
//! Cuprates address book is modeled as a [`tower::Service`]
|
||||
//! The request is [`AddressBookRequest`](monero_p2p::services::AddressBookRequest) and the response is
|
||||
//! [`AddressBookResponse`](monero_p2p::services::AddressBookResponse).
|
||||
//! The request is [`AddressBookRequest`](cuprate_p2p_core::services::AddressBookRequest) and the response is
|
||||
//! [`AddressBookResponse`](cuprate_p2p_core::services::AddressBookResponse).
|
||||
//!
|
||||
//! Cuprate, like monerod, actually has multiple address books, one
|
||||
//! for each [`NetworkZone`]. This is to reduce the possibility of
|
||||
|
@ -13,7 +13,7 @@
|
|||
//!
|
||||
use std::{io::ErrorKind, path::PathBuf, time::Duration};
|
||||
|
||||
use monero_p2p::NetworkZone;
|
||||
use cuprate_p2p_core::NetworkZone;
|
||||
|
||||
mod book;
|
||||
mod peer_list;
|
||||
|
|
|
@ -3,8 +3,8 @@ use std::collections::{BTreeMap, HashMap, HashSet};
|
|||
use indexmap::IndexMap;
|
||||
use rand::prelude::*;
|
||||
|
||||
use monero_p2p::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress, NetworkZone};
|
||||
use monero_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
use cuprate_p2p_core::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress, NetworkZone};
|
||||
use cuprate_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
|
|
@ -2,11 +2,9 @@ use std::collections::HashSet;
|
|||
|
||||
use rand::Rng;
|
||||
|
||||
use monero_p2p::services::ZoneSpecificPeerListEntryBase;
|
||||
use monero_pruning::PruningSeed;
|
||||
|
||||
use cuprate_p2p_core::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
use cuprate_test_utils::test_netzone::{TestNetZone, TestNetZoneAddr};
|
||||
use monero_p2p::NetZoneAddress;
|
||||
|
||||
use super::PeerList;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::fs;
|
|||
use borsh::{from_slice, to_vec, BorshDeserialize, BorshSerialize};
|
||||
use tokio::task::{spawn_blocking, JoinHandle};
|
||||
|
||||
use monero_p2p::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress, NetworkZone};
|
||||
use cuprate_p2p_core::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress, NetworkZone};
|
||||
|
||||
use crate::{peer_list::PeerList, AddressBookConfig};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "async-buffer"
|
||||
name = "cuprate-async-buffer"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use futures::{FutureExt, StreamExt};
|
||||
|
||||
use async_buffer::new_buffer;
|
||||
use cuprate_async_buffer::new_buffer;
|
||||
|
||||
#[tokio::test]
|
||||
async fn async_buffer_send_rec() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "dandelion-tower"
|
||||
name = "cuprate-dandelion-tower"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "monero-p2p"
|
||||
name = "cuprate-p2p-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
@ -7,12 +7,12 @@ authors = ["Boog900"]
|
|||
|
||||
[features]
|
||||
default = ["borsh"]
|
||||
borsh = ["dep:borsh", "monero-pruning/borsh"]
|
||||
borsh = ["dep:borsh", "cuprate-pruning/borsh"]
|
||||
|
||||
[dependencies]
|
||||
cuprate-helper = { path = "../../helper", features = ["asynch"], default-features = false }
|
||||
monero-wire = { path = "../../net/monero-wire", features = ["tracing"] }
|
||||
monero-pruning = { path = "../../pruning" }
|
||||
cuprate-wire = { path = "../../net/wire", features = ["tracing"] }
|
||||
cuprate-pruning = { path = "../../pruning" }
|
||||
|
||||
tokio = { workspace = true, features = ["net", "sync", "macros", "time"]}
|
||||
tokio-util = { workspace = true, features = ["codec"] }
|
|
@ -14,7 +14,7 @@ use tower::{Service, ServiceExt};
|
|||
use tracing::Instrument;
|
||||
|
||||
use cuprate_helper::asynch::InfallibleOneshotReceiver;
|
||||
use monero_pruning::PruningSeed;
|
||||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
use crate::{
|
||||
handles::{ConnectionGuard, ConnectionHandle},
|
|
@ -17,7 +17,7 @@ use tokio::{
|
|||
use tokio_stream::wrappers::ReceiverStream;
|
||||
use tower::ServiceExt;
|
||||
|
||||
use monero_wire::{LevinCommand, Message, ProtocolMessage};
|
||||
use cuprate_wire::{LevinCommand, Message, ProtocolMessage};
|
||||
|
||||
use crate::{
|
||||
constants::{REQUEST_TIMEOUT, SENDING_TIMEOUT},
|
||||
|
@ -241,7 +241,7 @@ where
|
|||
/// The main-loop for when we are in [`State::WaitingForRequest`].
|
||||
async fn state_waiting_for_request<Str>(&mut self, stream: &mut Str) -> Result<(), PeerError>
|
||||
where
|
||||
Str: FusedStream<Item = Result<Message, monero_wire::BucketError>> + Unpin,
|
||||
Str: FusedStream<Item = Result<Message, cuprate_wire::BucketError>> + Unpin,
|
||||
{
|
||||
tracing::debug!("waiting for peer/client request.");
|
||||
|
||||
|
@ -274,7 +274,7 @@ where
|
|||
/// The main-loop for when we are in [`State::WaitingForResponse`].
|
||||
async fn state_waiting_for_response<Str>(&mut self, stream: &mut Str) -> Result<(), PeerError>
|
||||
where
|
||||
Str: FusedStream<Item = Result<Message, monero_wire::BucketError>> + Unpin,
|
||||
Str: FusedStream<Item = Result<Message, cuprate_wire::BucketError>> + Unpin,
|
||||
{
|
||||
tracing::debug!("waiting for peer response.");
|
||||
|
||||
|
@ -306,7 +306,7 @@ where
|
|||
/// `eager_protocol_messages` are protocol messages that we received during a handshake.
|
||||
pub async fn run<Str>(mut self, mut stream: Str, eager_protocol_messages: Vec<ProtocolMessage>)
|
||||
where
|
||||
Str: FusedStream<Item = Result<Message, monero_wire::BucketError>> + Unpin,
|
||||
Str: FusedStream<Item = Result<Message, cuprate_wire::BucketError>> + Unpin,
|
||||
{
|
||||
tracing::debug!(
|
||||
"Handling eager messages len: {}",
|
|
@ -20,8 +20,8 @@ use tokio::{
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::{info_span, Instrument};
|
||||
|
||||
use monero_pruning::{PruningError, PruningSeed};
|
||||
use monero_wire::{
|
||||
use cuprate_pruning::{PruningError, PruningSeed};
|
||||
use cuprate_wire::{
|
||||
admin::{
|
||||
HandshakeRequest, HandshakeResponse, PingResponse, SupportFlagsResponse,
|
||||
PING_OK_RESPONSE_STATUS_TEXT,
|
||||
|
@ -586,7 +586,7 @@ async fn wait_for_message<Z: NetworkZone>(
|
|||
peer_sink: &mut Z::Sink,
|
||||
peer_stream: &mut Z::Stream,
|
||||
|
||||
eager_protocol_messages: &mut Vec<monero_wire::ProtocolMessage>,
|
||||
eager_protocol_messages: &mut Vec<cuprate_wire::ProtocolMessage>,
|
||||
|
||||
our_basic_node_data: &BasicNodeData,
|
||||
) -> Result<Message, HandshakeError> {
|
|
@ -5,7 +5,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use futures::channel::oneshot;
|
||||
use monero_wire::admin::TimedSyncRequest;
|
||||
use tokio::{
|
||||
sync::{mpsc, Semaphore},
|
||||
time::{interval, MissedTickBehavior},
|
||||
|
@ -13,6 +12,8 @@ use tokio::{
|
|||
use tower::ServiceExt;
|
||||
use tracing::instrument;
|
||||
|
||||
use cuprate_wire::admin::TimedSyncRequest;
|
||||
|
||||
use crate::{
|
||||
client::{connection::ConnectionTaskRequest, InternalPeerID},
|
||||
constants::{MAX_PEERS_IN_PEER_LIST_MESSAGE, TIMEOUT_INTERVAL},
|
|
@ -45,7 +45,7 @@ pub enum PeerError {
|
|||
#[error("inner service error: {0}")]
|
||||
ServiceError(#[from] tower::BoxError),
|
||||
#[error("bucket error: {0}")]
|
||||
BucketError(#[from] monero_wire::BucketError),
|
||||
BucketError(#[from] cuprate_wire::BucketError),
|
||||
#[error("handshake error: {0}")]
|
||||
Handshake(#[from] crate::client::HandshakeError),
|
||||
#[error("i/o error: {0}")]
|
|
@ -16,7 +16,7 @@ use std::{fmt::Debug, future::Future, hash::Hash, pin::Pin};
|
|||
|
||||
use futures::{Sink, Stream};
|
||||
|
||||
use monero_wire::{
|
||||
use cuprate_wire::{
|
||||
levin::LevinMessage, network_address::NetworkAddressIncorrectZone, BucketError, Message,
|
||||
NetworkAddress,
|
||||
};
|
|
@ -11,7 +11,7 @@ use tokio::net::{
|
|||
};
|
||||
use tokio_util::codec::{FramedRead, FramedWrite};
|
||||
|
||||
use monero_wire::MoneroWireCodec;
|
||||
use cuprate_wire::MoneroWireCodec;
|
||||
|
||||
use crate::{NetZoneAddress, NetworkZone};
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
//! Request: NewFluffyBlock, Response: None,
|
||||
//! Request: NewTransactions, Response: None
|
||||
//!
|
||||
use monero_wire::{
|
||||
use cuprate_wire::{
|
||||
admin::{
|
||||
HandshakeRequest, HandshakeResponse, PingResponse, SupportFlagsResponse, TimedSyncRequest,
|
||||
TimedSyncResponse,
|
|
@ -1,7 +1,7 @@
|
|||
//! This module contains the implementations of [`TryFrom`] and [`From`] to convert between
|
||||
//! [`Message`], [`PeerRequest`] and [`PeerResponse`].
|
||||
|
||||
use monero_wire::{Message, ProtocolMessage, RequestMessage, ResponseMessage};
|
||||
use cuprate_wire::{Message, ProtocolMessage, RequestMessage, ResponseMessage};
|
||||
|
||||
use super::{PeerRequest, PeerResponse};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use monero_pruning::{PruningError, PruningSeed};
|
||||
use monero_wire::{CoreSyncData, PeerListEntryBase};
|
||||
use cuprate_pruning::{PruningError, PruningSeed};
|
||||
use cuprate_wire::{CoreSyncData, PeerListEntryBase};
|
||||
|
||||
use crate::{
|
||||
client::InternalPeerID, handles::ConnectionHandle, NetZoneAddress, NetworkAddressIncorrectZone,
|
||||
|
@ -44,7 +44,7 @@ pub struct ZoneSpecificPeerListEntryBase<A: NetZoneAddress> {
|
|||
pub rpc_credits_per_hash: u32,
|
||||
}
|
||||
|
||||
impl<A: NetZoneAddress> From<ZoneSpecificPeerListEntryBase<A>> for monero_wire::PeerListEntryBase {
|
||||
impl<A: NetZoneAddress> From<ZoneSpecificPeerListEntryBase<A>> for cuprate_wire::PeerListEntryBase {
|
||||
fn from(value: ZoneSpecificPeerListEntryBase<A>) -> Self {
|
||||
Self {
|
||||
adr: value.adr.into(),
|
||||
|
@ -65,7 +65,7 @@ pub enum PeerListConversionError {
|
|||
PruningSeed(#[from] PruningError),
|
||||
}
|
||||
|
||||
impl<A: NetZoneAddress> TryFrom<monero_wire::PeerListEntryBase>
|
||||
impl<A: NetZoneAddress> TryFrom<cuprate_wire::PeerListEntryBase>
|
||||
for ZoneSpecificPeerListEntryBase<A>
|
||||
{
|
||||
type Error = PeerListConversionError;
|
|
@ -23,12 +23,12 @@ use tokio_util::{
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_helper::network::Network;
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::{ConnectRequest, Connector, DoHandshakeRequest, HandShaker, InternalPeerID},
|
||||
network_zones::ClearNetServerCfg,
|
||||
ConnectionDirection, NetworkZone,
|
||||
};
|
||||
use monero_wire::{
|
||||
use cuprate_wire::{
|
||||
common::PeerSupportFlags,
|
||||
levin::{message::make_fragmented_messages, LevinMessage, Protocol},
|
||||
BasicNodeData, Message, MoneroWireCodec,
|
|
@ -2,7 +2,7 @@ use std::{sync::Arc, time::Duration};
|
|||
|
||||
use tokio::sync::Semaphore;
|
||||
|
||||
use monero_p2p::handles::HandleBuilder;
|
||||
use cuprate_p2p_core::handles::HandleBuilder;
|
||||
|
||||
#[test]
|
||||
fn send_ban_signal() {
|
|
@ -10,9 +10,9 @@ use tokio_util::codec::{FramedRead, FramedWrite};
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_helper::network::Network;
|
||||
use monero_wire::{common::PeerSupportFlags, BasicNodeData, MoneroWireCodec};
|
||||
use cuprate_wire::{common::PeerSupportFlags, BasicNodeData, MoneroWireCodec};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::{ConnectRequest, Connector, DoHandshakeRequest, HandShaker, InternalPeerID},
|
||||
network_zones::{ClearNet, ClearNetServerCfg},
|
||||
ConnectionDirection, NetworkZone,
|
|
@ -4,9 +4,9 @@ use tokio::sync::Semaphore;
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_helper::network::Network;
|
||||
use monero_wire::{common::PeerSupportFlags, protocol::GetObjectsRequest, BasicNodeData};
|
||||
use cuprate_wire::{common::PeerSupportFlags, protocol::GetObjectsRequest, BasicNodeData};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::{ConnectRequest, Connector, HandShaker},
|
||||
network_zones::ClearNet,
|
||||
protocol::{PeerRequest, PeerResponse},
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
use futures::FutureExt;
|
||||
use tower::Service;
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
services::{
|
||||
AddressBookRequest, AddressBookResponse, CoreSyncDataRequest, CoreSyncDataResponse,
|
||||
PeerSyncRequest, PeerSyncResponse,
|
||||
|
@ -54,7 +54,7 @@ impl Service<CoreSyncDataRequest> for DummyCoreSyncSvc {
|
|||
|
||||
fn call(&mut self, _: CoreSyncDataRequest) -> Self::Future {
|
||||
async move {
|
||||
Ok(CoreSyncDataResponse(monero_wire::CoreSyncData {
|
||||
Ok(CoreSyncDataResponse(cuprate_wire::CoreSyncData {
|
||||
cumulative_difficulty: 1,
|
||||
cumulative_difficulty_top64: 0,
|
||||
current_height: 1,
|
|
@ -6,13 +6,13 @@ license = "MIT"
|
|||
authors = ["Boog900"]
|
||||
|
||||
[dependencies]
|
||||
fixed-bytes = { path = "../../net/fixed-bytes" }
|
||||
monero-wire = { path = "../../net/monero-wire" }
|
||||
monero-p2p = { path = "../monero-p2p", features = ["borsh"] }
|
||||
monero-address-book = { path = "../address-book" }
|
||||
monero-pruning = { path = "../../pruning" }
|
||||
cuprate-fixed-bytes = { path = "../../net/fixed-bytes" }
|
||||
cuprate-wire = { path = "../../net/wire" }
|
||||
cuprate-p2p-core = { path = "../p2p-core", features = ["borsh"] }
|
||||
cuprate-address-book = { path = "../address-book" }
|
||||
cuprate-pruning = { path = "../../pruning" }
|
||||
cuprate-helper = { path = "../../helper", features = ["asynch"], default-features = false }
|
||||
async-buffer = { path = "../async-buffer" }
|
||||
cuprate-async-buffer = { path = "../async-buffer" }
|
||||
|
||||
monero-serai = { workspace = true, features = ["std"] }
|
||||
|
|
@ -21,13 +21,13 @@ use tokio::{
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::{instrument, Instrument, Span};
|
||||
|
||||
use async_buffer::{BufferAppender, BufferStream};
|
||||
use monero_p2p::{
|
||||
use cuprate_async_buffer::{BufferAppender, BufferStream};
|
||||
use cuprate_p2p_core::{
|
||||
handles::ConnectionHandle,
|
||||
services::{PeerSyncRequest, PeerSyncResponse},
|
||||
NetworkZone, PeerSyncSvc,
|
||||
};
|
||||
use monero_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
use cuprate_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
|
||||
use crate::{
|
||||
client_pool::{ClientPool, ClientPoolDropGuard},
|
||||
|
@ -150,7 +150,7 @@ where
|
|||
+ 'static,
|
||||
C::Future: Send + 'static,
|
||||
{
|
||||
let (buffer_appender, buffer_stream) = async_buffer::new_buffer(config.buffer_size);
|
||||
let (buffer_appender, buffer_stream) = cuprate_async_buffer::new_buffer(config.buffer_size);
|
||||
|
||||
let block_downloader = BlockDownloader::new(
|
||||
client_pool,
|
|
@ -1,6 +1,6 @@
|
|||
use std::{cmp::Ordering, collections::BinaryHeap};
|
||||
|
||||
use async_buffer::BufferAppender;
|
||||
use cuprate_async_buffer::BufferAppender;
|
||||
|
||||
use super::{BlockBatch, BlockDownloadError};
|
||||
|
||||
|
@ -120,7 +120,7 @@ mod tests {
|
|||
use tokio::sync::Semaphore;
|
||||
use tokio_test::block_on;
|
||||
|
||||
use monero_p2p::handles::HandleBuilder;
|
||||
use cuprate_p2p_core::handles::HandleBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -144,7 +144,7 @@ mod tests {
|
|||
#[test]
|
||||
fn block_queue_returns_items_in_order(batches in vec(ready_batch_strategy(), 0..10_000)) {
|
||||
block_on(async move {
|
||||
let (buffer_tx, mut buffer_rx) = async_buffer::new_buffer(usize::MAX);
|
||||
let (buffer_tx, mut buffer_rx) = cuprate_async_buffer::new_buffer(usize::MAX);
|
||||
|
||||
let mut queue = BlockQueue::new(buffer_tx);
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
use std::{cmp::min, collections::VecDeque};
|
||||
|
||||
use fixed_bytes::ByteArrayVec;
|
||||
use cuprate_fixed_bytes::ByteArrayVec;
|
||||
|
||||
use monero_p2p::{client::InternalPeerID, handles::ConnectionHandle, NetworkZone};
|
||||
use monero_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
use cuprate_p2p_core::{client::InternalPeerID, handles::ConnectionHandle, NetworkZone};
|
||||
use cuprate_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
|
||||
use crate::constants::MEDIUM_BAN;
|
||||
|
|
@ -6,10 +6,10 @@ use tokio::time::timeout;
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::instrument;
|
||||
|
||||
use cuprate_fixed_bytes::ByteArrayVec;
|
||||
use cuprate_helper::asynch::rayon_spawn_async;
|
||||
use fixed_bytes::ByteArrayVec;
|
||||
use monero_p2p::{handles::ConnectionHandle, NetworkZone, PeerRequest, PeerResponse};
|
||||
use monero_wire::protocol::{GetObjectsRequest, GetObjectsResponse};
|
||||
use cuprate_p2p_core::{handles::ConnectionHandle, NetworkZone, PeerRequest, PeerResponse};
|
||||
use cuprate_wire::protocol::{GetObjectsRequest, GetObjectsResponse};
|
||||
|
||||
use crate::{
|
||||
block_downloader::{BlockBatch, BlockDownloadError, BlockDownloadTaskResponse},
|
|
@ -6,13 +6,13 @@ use tokio::{task::JoinSet, time::timeout};
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::{instrument, Instrument, Span};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::InternalPeerID,
|
||||
handles::ConnectionHandle,
|
||||
services::{PeerSyncRequest, PeerSyncResponse},
|
||||
NetworkZone, PeerRequest, PeerResponse, PeerSyncSvc,
|
||||
};
|
||||
use monero_wire::protocol::{ChainRequest, ChainResponse};
|
||||
use cuprate_wire::protocol::{ChainRequest, ChainResponse};
|
||||
|
||||
use crate::{
|
||||
block_downloader::{
|
|
@ -18,15 +18,15 @@ use proptest::{collection::vec, prelude::*};
|
|||
use tokio::{sync::Semaphore, time::timeout};
|
||||
use tower::{service_fn, Service};
|
||||
|
||||
use fixed_bytes::ByteArrayVec;
|
||||
use monero_p2p::{
|
||||
use cuprate_fixed_bytes::ByteArrayVec;
|
||||
use cuprate_p2p_core::{
|
||||
client::{mock_client, Client, InternalPeerID, PeerInformation},
|
||||
network_zones::ClearNet,
|
||||
services::{PeerSyncRequest, PeerSyncResponse},
|
||||
ConnectionDirection, NetworkZone, PeerRequest, PeerResponse,
|
||||
};
|
||||
use monero_pruning::PruningSeed;
|
||||
use monero_wire::{
|
||||
use cuprate_pruning::PruningSeed;
|
||||
use cuprate_wire::{
|
||||
common::{BlockCompleteEntry, TransactionBlobs},
|
||||
protocol::{ChainResponse, GetObjectsResponse},
|
||||
};
|
||||
|
@ -184,7 +184,7 @@ prop_compose! {
|
|||
fn mock_block_downloader_client(blockchain: Arc<MockBlockchain>) -> Client<ClearNet> {
|
||||
let semaphore = Arc::new(Semaphore::new(1));
|
||||
|
||||
let (connection_guard, connection_handle) = monero_p2p::handles::HandleBuilder::new()
|
||||
let (connection_guard, connection_handle) = cuprate_p2p_core::handles::HandleBuilder::new()
|
||||
.with_permit(semaphore.try_acquire_owned().unwrap())
|
||||
.build();
|
||||
|
|
@ -22,8 +22,10 @@ use tokio::{
|
|||
use tokio_stream::wrappers::WatchStream;
|
||||
use tower::Service;
|
||||
|
||||
use monero_p2p::{client::InternalPeerID, BroadcastMessage, ConnectionDirection, NetworkZone};
|
||||
use monero_wire::{
|
||||
use cuprate_p2p_core::{
|
||||
client::InternalPeerID, BroadcastMessage, ConnectionDirection, NetworkZone,
|
||||
};
|
||||
use cuprate_wire::{
|
||||
common::{BlockCompleteEntry, TransactionBlobs},
|
||||
protocol::{NewFluffyBlock, NewTransactions},
|
||||
};
|
||||
|
@ -128,7 +130,7 @@ pub fn init_broadcast_channels<N: NetworkZone>(
|
|||
/// Only certain P2P messages are supported here: [`NewFluffyBlock`] and [`NewTransactions`]. These are the only
|
||||
/// P2P messages that make sense to broadcast to multiple peers.
|
||||
///
|
||||
/// [`NewBlock`](monero_wire::protocol::NewBlock) has been excluded as monerod has had fluffy blocks for a while and
|
||||
/// [`NewBlock`](cuprate_wire::protocol::NewBlock) has been excluded as monerod has had fluffy blocks for a while and
|
||||
/// Cuprate sets fluffy blocks as a requirement during handshakes.
|
||||
pub enum BroadcastRequest<N: NetworkZone> {
|
||||
/// Broadcast a block to the network. The block will be broadcast as a fluffy block to all peers.
|
||||
|
@ -400,8 +402,8 @@ mod tests {
|
|||
use tokio::time::timeout;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_p2p_core::{client::InternalPeerID, BroadcastMessage, ConnectionDirection};
|
||||
use cuprate_test_utils::test_netzone::TestNetZone;
|
||||
use monero_p2p::{client::InternalPeerID, BroadcastMessage, ConnectionDirection};
|
||||
|
||||
use super::{init_broadcast_channels, BroadcastConfig, BroadcastRequest};
|
||||
|
|
@ -16,7 +16,7 @@ use dashmap::DashMap;
|
|||
use tokio::sync::mpsc;
|
||||
use tracing::{Instrument, Span};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::{Client, InternalPeerID},
|
||||
handles::ConnectionHandle,
|
||||
NetworkZone,
|
|
@ -14,7 +14,7 @@ use tokio::sync::mpsc;
|
|||
use tokio_util::sync::WaitForCancellationFutureOwned;
|
||||
use tracing::instrument;
|
||||
|
||||
use monero_p2p::{client::InternalPeerID, handles::ConnectionHandle, NetworkZone};
|
||||
use cuprate_p2p_core::{client::InternalPeerID, handles::ConnectionHandle, NetworkZone};
|
||||
|
||||
use super::ClientPool;
|
||||
|
|
@ -3,7 +3,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use monero_p2p::{client::Client, NetworkZone};
|
||||
use cuprate_p2p_core::{client::Client, NetworkZone};
|
||||
|
||||
use crate::client_pool::ClientPool;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use cuprate_address_book::AddressBookConfig;
|
||||
use cuprate_helper::network::Network;
|
||||
use monero_address_book::AddressBookConfig;
|
||||
use monero_p2p::NetworkZone;
|
||||
use monero_wire::{common::PeerSupportFlags, BasicNodeData};
|
||||
use cuprate_p2p_core::NetworkZone;
|
||||
use cuprate_wire::{common::PeerSupportFlags, BasicNodeData};
|
||||
|
||||
/// P2P config.
|
||||
#[derive(Clone, Debug)]
|
|
@ -14,7 +14,7 @@ use tokio::{
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::{instrument, Instrument, Span};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::{Client, ConnectRequest, HandshakeError},
|
||||
services::{AddressBookRequest, AddressBookResponse},
|
||||
AddressBook, NetworkZone,
|
|
@ -12,7 +12,7 @@ use tokio::{
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::{instrument, Instrument, Span};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::{Client, DoHandshakeRequest, HandshakeError, InternalPeerID},
|
||||
services::{AddressBookRequest, AddressBookResponse},
|
||||
AddressBook, ConnectionDirection, NetworkZone,
|
|
@ -4,7 +4,7 @@
|
|||
//! a certain [`NetworkZone`]
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_buffer::BufferStream;
|
||||
use cuprate_async_buffer::BufferStream;
|
||||
use futures::FutureExt;
|
||||
use tokio::{
|
||||
sync::{mpsc, watch},
|
||||
|
@ -14,7 +14,7 @@ use tokio_stream::wrappers::WatchStream;
|
|||
use tower::{buffer::Buffer, util::BoxCloneService, Service, ServiceExt};
|
||||
use tracing::{instrument, Instrument, Span};
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::Connector,
|
||||
client::InternalPeerID,
|
||||
services::{AddressBookRequest, AddressBookResponse, PeerSyncRequest},
|
||||
|
@ -56,7 +56,7 @@ where
|
|||
CS: CoreSyncSvc + Clone,
|
||||
{
|
||||
let address_book =
|
||||
monero_address_book::init_address_book(config.address_book_config.clone()).await?;
|
||||
cuprate_address_book::init_address_book(config.address_book_config.clone()).await?;
|
||||
let address_book = Buffer::new(
|
||||
address_book,
|
||||
config.max_inbound_connections + config.outbound_connections,
|
||||
|
@ -79,7 +79,7 @@ where
|
|||
basic_node_data.peer_id = 1;
|
||||
}
|
||||
|
||||
let outbound_handshaker = monero_p2p::client::HandShaker::new(
|
||||
let outbound_handshaker = cuprate_p2p_core::client::HandShaker::new(
|
||||
address_book.clone(),
|
||||
sync_states_svc.clone(),
|
||||
core_sync_svc.clone(),
|
||||
|
@ -88,7 +88,7 @@ where
|
|||
basic_node_data.clone(),
|
||||
);
|
||||
|
||||
let inbound_handshaker = monero_p2p::client::HandShaker::new(
|
||||
let inbound_handshaker = cuprate_p2p_core::client::HandShaker::new(
|
||||
address_book.clone(),
|
||||
sync_states_svc.clone(),
|
||||
core_sync_svc.clone(),
|
|
@ -13,14 +13,14 @@ use futures::{stream::FuturesUnordered, StreamExt};
|
|||
use tokio::sync::watch;
|
||||
use tower::Service;
|
||||
|
||||
use monero_p2p::{
|
||||
use cuprate_p2p_core::{
|
||||
client::InternalPeerID,
|
||||
handles::ConnectionHandle,
|
||||
services::{PeerSyncRequest, PeerSyncResponse},
|
||||
NetworkZone,
|
||||
};
|
||||
use monero_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
use monero_wire::CoreSyncData;
|
||||
use cuprate_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT};
|
||||
use cuprate_wire::CoreSyncData;
|
||||
|
||||
use crate::{client_pool::disconnect_monitor::PeerDisconnectFut, constants::SHORT_BAN};
|
||||
|
||||
|
@ -243,11 +243,13 @@ mod tests {
|
|||
use tokio::sync::Semaphore;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
use monero_p2p::{client::InternalPeerID, handles::HandleBuilder, services::PeerSyncRequest};
|
||||
use monero_wire::CoreSyncData;
|
||||
use cuprate_p2p_core::{
|
||||
client::InternalPeerID, handles::HandleBuilder, services::PeerSyncRequest,
|
||||
};
|
||||
use cuprate_wire::CoreSyncData;
|
||||
|
||||
use cuprate_p2p_core::services::PeerSyncResponse;
|
||||
use cuprate_test_utils::test_netzone::TestNetZone;
|
||||
use monero_p2p::services::PeerSyncResponse;
|
||||
|
||||
use super::PeerSyncSvc;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "monero-pruning"
|
||||
name = "cuprate-pruning"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//! split into 8 parts):
|
||||
//!
|
||||
//! ```rust
|
||||
//! use monero_pruning::PruningSeed;
|
||||
//! use cuprate_pruning::PruningSeed;
|
||||
//!
|
||||
//! let seed: u32 = 386; // the seed you want to check is valid
|
||||
//! match PruningSeed::decompress_p2p_rules(seed) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "json-rpc"
|
||||
name = "cuprate-json-rpc"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
description = "JSON-RPC 2.0 implementation"
|
||||
|
|
|
@ -30,7 +30,7 @@ and assumes the type within that `body` field is tagged properly, for example:
|
|||
```rust
|
||||
# use pretty_assertions::assert_eq;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use json_rpc::{Id, Request};
|
||||
use cuprate_json_rpc::{Id, Request};
|
||||
|
||||
// Parameter type.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
@ -83,7 +83,7 @@ This crate's serialized field order slightly differs compared to `monerod`.
|
|||
With that said, parsing should be not affected at all since a key-value map is used:
|
||||
```rust
|
||||
# use pretty_assertions::assert_eq;
|
||||
use json_rpc::{Id, Response};
|
||||
use cuprate_json_rpc::{Id, Response};
|
||||
|
||||
let response = Response::ok(Id::Num(123), "OK");
|
||||
let response_json = serde_json::to_string_pretty(&response).unwrap();
|
||||
|
@ -147,7 +147,7 @@ A quick table showing some small differences between this crate and other JSON-R
|
|||
|
||||
Allows any case for key fields excluding `method/params`:
|
||||
```rust
|
||||
# use json_rpc::Response;
|
||||
# use cuprate_json_rpc::Response;
|
||||
# use serde_json::from_str;
|
||||
# use pretty_assertions::assert_eq;
|
||||
let json = r#"{"jsonrpc":"2.0","id":123,"result":"OK"}"#;
|
||||
|
@ -161,7 +161,7 @@ assert_eq!(format!("{err}"), "missing field `jsonrpc` at line 1 column 40");
|
|||
|
||||
Allows unknown fields in main `{}`, and response/request objects:
|
||||
```rust
|
||||
# use json_rpc::Response;
|
||||
# use cuprate_json_rpc::Response;
|
||||
# use serde_json::from_str;
|
||||
// unknown fields are allowed in main `{}`
|
||||
// v
|
||||
|
@ -176,7 +176,7 @@ from_str::<Response<String>>(&json).unwrap();
|
|||
|
||||
Allows overwriting previous values upon duplicate fields (except [`Response`]'s `result/error` field)
|
||||
```rust
|
||||
# use json_rpc::{Id, Response};
|
||||
# use cuprate_json_rpc::{Id, Response};
|
||||
# use serde_json::from_str;
|
||||
# use pretty_assertions::assert_eq;
|
||||
// duplicate fields will get overwritten by the latest one
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::error::constants::{
|
|||
///
|
||||
/// # Display
|
||||
/// ```rust
|
||||
/// use json_rpc::error::ErrorCode;
|
||||
/// use cuprate_json_rpc::error::ErrorCode;
|
||||
/// use serde_json::{to_value, from_value, Value};
|
||||
///
|
||||
/// for e in [
|
||||
|
@ -46,7 +46,7 @@ use crate::error::constants::{
|
|||
/// # (De)serialization
|
||||
/// This type gets (de)serialized as the associated `i32`, for example:
|
||||
/// ```rust
|
||||
/// use json_rpc::error::ErrorCode;
|
||||
/// use cuprate_json_rpc::error::ErrorCode;
|
||||
/// use serde_json::{to_value, from_value, Value};
|
||||
///
|
||||
/// for e in [
|
||||
|
@ -69,7 +69,7 @@ use crate::error::constants::{
|
|||
/// ```
|
||||
///
|
||||
/// ```rust,should_panic
|
||||
/// # use json_rpc::error::ErrorCode;
|
||||
/// # use cuprate_json_rpc::error::ErrorCode;
|
||||
/// # use serde_json::from_value;
|
||||
/// // A JSON string that contains an integer won't work.
|
||||
/// from_value::<ErrorCode>("-32700".into()).unwrap();
|
||||
|
@ -109,7 +109,7 @@ impl ErrorCode {
|
|||
/// [`From<i32>`] is the same as this function.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::error::{
|
||||
/// use cuprate_json_rpc::error::{
|
||||
/// ErrorCode,
|
||||
/// INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERROR,
|
||||
/// };
|
||||
|
@ -147,7 +147,7 @@ impl ErrorCode {
|
|||
/// Returns `self`'s [`i32`] code representation.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::error::{
|
||||
/// use cuprate_json_rpc::error::{
|
||||
/// ErrorCode,
|
||||
/// INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERROR,
|
||||
/// };
|
||||
|
@ -174,7 +174,7 @@ impl ErrorCode {
|
|||
/// Returns `self`'s human readable [`str`] message.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::error::{
|
||||
/// use cuprate_json_rpc::error::{
|
||||
/// ErrorCode,
|
||||
/// INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERROR, SERVER_ERROR,
|
||||
/// };
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::error::{
|
|||
///
|
||||
/// # Display
|
||||
/// ```rust
|
||||
/// use json_rpc::error::ErrorObject;
|
||||
/// use cuprate_json_rpc::error::ErrorObject;
|
||||
///
|
||||
/// // The format is `$CODE: $MESSAGE`.
|
||||
/// // If a message was not passed during construction,
|
||||
|
@ -69,7 +69,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// for code in [
|
||||
/// ErrorCode::ParseError,
|
||||
|
@ -100,7 +100,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// let code = ErrorCode::ParseError;
|
||||
/// let object = ErrorObject::parse_error();
|
||||
|
@ -122,7 +122,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// let code = ErrorCode::InvalidRequest;
|
||||
/// let object = ErrorObject::invalid_request();
|
||||
|
@ -144,7 +144,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// let code = ErrorCode::MethodNotFound;
|
||||
/// let object = ErrorObject::method_not_found();
|
||||
|
@ -166,7 +166,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// let code = ErrorCode::InvalidParams;
|
||||
/// let object = ErrorObject::invalid_params();
|
||||
|
@ -189,7 +189,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// let code = ErrorCode::InternalError;
|
||||
/// let object = ErrorObject::internal_error();
|
||||
|
@ -213,7 +213,7 @@ impl ErrorObject {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::error::{ErrorCode, ErrorObject};
|
||||
/// use cuprate_json_rpc::error::{ErrorCode, ErrorObject};
|
||||
///
|
||||
/// let code = ErrorCode::ServerError(0);
|
||||
/// let object = ErrorObject::server_error(0);
|
||||
|
|
|
@ -26,7 +26,7 @@ use std::borrow::Cow;
|
|||
/// (or just manually create the `Cow`) for a non-allocating `Id`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
///
|
||||
/// assert_eq!(Id::from(String::new()), Id::Str("".into()));
|
||||
/// assert_eq!(Id::from(Some(String::new())), Id::Str("".into()));
|
||||
|
@ -39,7 +39,7 @@ pub enum Id {
|
|||
/// A JSON `null` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
/// use serde_json::{from_value,to_value,json,Value};
|
||||
///
|
||||
/// assert_eq!(from_value::<Id>(json!(null)).unwrap(), Id::Null);
|
||||
|
@ -61,7 +61,7 @@ pub enum Id {
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::borrow::Cow;
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
///
|
||||
/// /// A program's static ID.
|
||||
/// const ID: &'static str = "my_id";
|
||||
|
@ -79,7 +79,7 @@ impl Id {
|
|||
/// This returns `Some(u64)` if [`Id`] is a number.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
///
|
||||
/// assert_eq!(Id::Num(0).as_u64(), Some(0));
|
||||
/// assert_eq!(Id::Str("0".into()).as_u64(), None);
|
||||
|
@ -95,7 +95,7 @@ impl Id {
|
|||
/// This returns `Some(&str)` if [`Id`] is a string.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
///
|
||||
/// assert_eq!(Id::Str("0".into()).as_str(), Some("0"));
|
||||
/// assert_eq!(Id::Num(0).as_str(), None);
|
||||
|
@ -111,7 +111,7 @@ impl Id {
|
|||
/// Returns `true` if `self` is [`Id::Null`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
///
|
||||
/// assert!(Id::Null.is_null());
|
||||
/// assert!(!Id::Num(0).is_null());
|
||||
|
@ -124,7 +124,7 @@ impl Id {
|
|||
/// Create a new [`Id::Str`] from a static string.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Id;
|
||||
/// use cuprate_json_rpc::Id;
|
||||
///
|
||||
/// assert_eq!(Id::from_static_str("hi"), Id::Str("hi".into()));
|
||||
/// ```
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<T> Request<T> {
|
|||
/// Create a new [`Self`] with no [`Id`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::Request;
|
||||
/// use cuprate_json_rpc::Request;
|
||||
///
|
||||
/// assert_eq!(Request::new("").id, None);
|
||||
/// ```
|
||||
|
@ -62,7 +62,7 @@ impl<T> Request<T> {
|
|||
/// Create a new [`Self`] with an [`Id`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Request};
|
||||
/// use cuprate_json_rpc::{Id, Request};
|
||||
///
|
||||
/// assert_eq!(Request::new_with_id(Id::Num(0), "").id, Some(Id::Num(0)));
|
||||
/// ```
|
||||
|
@ -79,7 +79,7 @@ impl<T> Request<T> {
|
|||
/// In other words, if `id` is [`None`], this returns `true`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Request};
|
||||
/// use cuprate_json_rpc::{Id, Request};
|
||||
///
|
||||
/// assert!(Request::new("").is_notification());
|
||||
/// assert!(!Request::new_with_id(Id::Null, "").is_notification());
|
||||
|
|
|
@ -37,7 +37,7 @@ impl<T> Response<T> {
|
|||
/// Creates a successful response.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response};
|
||||
/// use cuprate_json_rpc::{Id, Response};
|
||||
///
|
||||
/// let ok = Response::ok(Id::Num(123), "OK");
|
||||
/// let json = serde_json::to_string(&ok).unwrap();
|
||||
|
@ -54,7 +54,7 @@ impl<T> Response<T> {
|
|||
/// Creates an error response.
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
/// use cuprate_json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
///
|
||||
/// let err = ErrorObject {
|
||||
/// code: 0.into(),
|
||||
|
@ -77,7 +77,7 @@ impl<T> Response<T> {
|
|||
/// Creates an error response using [`ErrorObject::parse_error`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
/// use cuprate_json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
///
|
||||
/// let ok = Response::<()>::parse_error(Id::Num(0));
|
||||
/// let json = serde_json::to_string(&ok).unwrap();
|
||||
|
@ -94,7 +94,7 @@ impl<T> Response<T> {
|
|||
/// Creates an error response using [`ErrorObject::invalid_request`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
/// use cuprate_json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
///
|
||||
/// let ok = Response::<()>::invalid_request(Id::Num(0));
|
||||
/// let json = serde_json::to_string(&ok).unwrap();
|
||||
|
@ -111,7 +111,7 @@ impl<T> Response<T> {
|
|||
/// Creates an error response using [`ErrorObject::method_not_found`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
/// use cuprate_json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
///
|
||||
/// let ok = Response::<()>::method_not_found(Id::Num(0));
|
||||
/// let json = serde_json::to_string(&ok).unwrap();
|
||||
|
@ -128,7 +128,7 @@ impl<T> Response<T> {
|
|||
/// Creates an error response using [`ErrorObject::invalid_params`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
/// use cuprate_json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
///
|
||||
/// let ok = Response::<()>::invalid_params(Id::Num(0));
|
||||
/// let json = serde_json::to_string(&ok).unwrap();
|
||||
|
@ -145,7 +145,7 @@ impl<T> Response<T> {
|
|||
/// Creates an error response using [`ErrorObject::internal_error`].
|
||||
///
|
||||
/// ```rust
|
||||
/// use json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
/// use cuprate_json_rpc::{Id, Response, error::{ErrorObject, ErrorCode}};
|
||||
///
|
||||
/// let ok = Response::<()>::internal_error(Id::Num(0));
|
||||
/// let json = serde_json::to_string(&ok).unwrap();
|
||||
|
|
|
@ -26,7 +26,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// use json_rpc::Version;
|
||||
/// use cuprate_json_rpc::Version;
|
||||
/// use serde_json::{to_string, to_string_pretty, from_str};
|
||||
///
|
||||
/// assert_eq!(Version::TWO, "2.0");
|
||||
|
@ -64,7 +64,7 @@ impl Version {
|
|||
/// Note that this does not have extra quotes to mark
|
||||
/// that it's a JSON string and not a float.
|
||||
/// ```rust
|
||||
/// use json_rpc::Version;
|
||||
/// use cuprate_json_rpc::Version;
|
||||
///
|
||||
/// let string = format!("{}", Version);
|
||||
/// assert_eq!(string, "2.0");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "monero-rpc-types"
|
||||
name = "cuprate-rpc-types"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
description = "Monero RPC types"
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue