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