Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2024"

[dependencies]
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = false, rev = "2b07f59545de16b66b3bf8ee988757c2d0c14afb" }
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = false, rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }

[dev-dependencies]
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2b07f59545de16b66b3bf8ee988757c2d0c14afb" }
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }
rusqlite = { version = "0.36.0", features = ["bundled"] }
3 changes: 2 additions & 1 deletion p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ categories = ["cryptography::cryptocurrencies"]
rust-version = "1.75.0"

[dependencies]
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2b07f59545de16b66b3bf8ee988757c2d0c14afb" }
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }
p2p = { package = "bitcoin-p2p-messages", git = "https://github.com/rust-bitcoin/rust-bitcoin", rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }
tokio = { version = "1", default-features = false, optional = true, features = [
"sync",
"io-util",
Expand Down
10 changes: 5 additions & 5 deletions p2p/examples/update_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use std::{
use accumulator::Accumulator;
use bitcoin::{
block::BlockUncheckedExt,
p2p::{
message::NetworkMessage,
message_blockdata::{GetBlocksMessage, Inventory},
ServiceFlags,
},
secp256k1::rand::{seq::SliceRandom, thread_rng},
BlockHash, Network, OutPoint,
};
use p2p::{
message::NetworkMessage,
message_blockdata::{GetBlocksMessage, Inventory},
ServiceFlags,
};
use peers::{
dns::{DnsQuery, TokioDnsExt},
PortExt,
Expand Down
21 changes: 12 additions & 9 deletions p2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ use std::{
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};

use bitcoin::{
consensus,
p2p::{
message::{CommandString, NetworkMessage, RawNetworkMessage},
message_network::VersionMessage,
Address, Magic, ServiceFlags,
},
FeeRate, Network,
use bitcoin::{consensus, FeeRate, Network};
use p2p::{
message::{CommandString, NetworkMessage, RawNetworkMessage},
message_network::VersionMessage,
Address, Magic, ServiceFlags,
};
use validation::ValidationExt;

Expand Down Expand Up @@ -639,7 +636,7 @@ macro_rules! define_version_message_logic {
}

let mut negotiation = Negotiation::default();
let magic = Magic::from_params($conn.network);
let magic = Magic::from_params($conn.network).expect("unknown network");
let mut write_half = WriteHalf::V1(magic);
let mut read_half = ReadHalf::V1(magic);
let nonce = rand::random();
Expand Down Expand Up @@ -723,6 +720,7 @@ macro_rules! define_version_message_logic {
}};
}

#[cfg(feature = "tokio")]
macro_rules! async_awaiter {
($e:expr) => {
$e.await
Expand All @@ -735,6 +733,7 @@ macro_rules! blocking_awaiter {
};
}

#[cfg(feature = "tokio")]
macro_rules! read_message_async {
($reader:expr, $magic:expr) => {
$crate::define_read_message_logic!(async_awaiter, $reader, $magic)
Expand All @@ -753,15 +752,19 @@ macro_rules! version_handshake_blocking {
};
}

#[cfg(feature = "tokio")]
macro_rules! version_handshake_async {
($reader:expr, $conn:ident) => {
$crate::define_version_message_logic!(async_awaiter, $reader, $conn)
};
}

#[cfg(feature = "tokio")]
pub(crate) use async_awaiter;
pub(crate) use blocking_awaiter;
#[cfg(feature = "tokio")]
pub(crate) use read_message_async;
pub(crate) use read_message_blocking;
#[cfg(feature = "tokio")]
pub(crate) use version_handshake_async;
pub(crate) use version_handshake_blocking;
9 changes: 5 additions & 4 deletions p2p/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use std::{
net::{SocketAddr, TcpStream},
};

use bitcoin::p2p::message::NetworkMessage;
use bitcoin::p2p::message::RawNetworkMessage;
use bitcoin::p2p::Magic;
use bitcoin::consensus;
use bitcoin::secp256k1::rand;
use bitcoin::{consensus, p2p::message_compact_blocks::SendCmpct};
use p2p::message::NetworkMessage;
use p2p::message::RawNetworkMessage;
use p2p::message_compact_blocks::SendCmpct;
use p2p::Magic;

use crate::{
blocking_awaiter, interpret_first_message, make_version, version_handshake_blocking,
Expand Down
7 changes: 4 additions & 3 deletions p2p/src/tokio_ext.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use ::std::fmt::{Debug, Display};
use std::net::SocketAddr;

use bitcoin::p2p::message::{NetworkMessage, RawNetworkMessage};
use bitcoin::p2p::message_compact_blocks::SendCmpct;
use bitcoin::consensus;
use bitcoin::secp256k1::rand;
use bitcoin::{consensus, p2p::Magic};
use p2p::message::{NetworkMessage, RawNetworkMessage};
use p2p::message_compact_blocks::SendCmpct;
use p2p::Magic;
use tokio::io::AsyncWriteExt;
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
use tokio::{
Expand Down
3 changes: 2 additions & 1 deletion p2p/src/validation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bitcoin::{block::HeaderExt, p2p::message_blockdata::Inventory, BlockHeader};
use bitcoin::{block::HeaderExt, BlockHeader};
use p2p::message_blockdata::Inventory;

pub(crate) trait ValidationExt {
fn is_valid(&self) -> bool;
Expand Down
8 changes: 3 additions & 5 deletions p2p/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::net::SocketAddrV4;

use bitcoin::{
p2p::{message::NetworkMessage, ServiceFlags},
BlockHash, Network,
};
use bitcoin::{BlockHash, Network};
use corepc_node::{exe_path, P2P};
use p2p::{message::NetworkMessage, ServiceFlags};
use swiftsync_p2p::ConnectionBuilder;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -61,7 +59,7 @@ fn filters_unsupported_messages() {
let err = tcp_stream.write_message(NetworkMessage::MemPool, &mut ctx);
assert!(err.is_err());
let err = tcp_stream.write_message(
NetworkMessage::GetCFilters(bitcoin::p2p::message_filter::GetCFilters {
NetworkMessage::GetCFilters(p2p::message_filter::GetCFilters {
filter_type: 0x00,
start_height: 0.into(),
stop_hash: BlockHash::from_byte_array([0; 32]),
Expand Down
2 changes: 1 addition & 1 deletion peers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"

[dependencies]
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2b07f59545de16b66b3bf8ee988757c2d0c14afb" }
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }
tokio = { version = "1", default-features = false, optional = true, features = [
"io-util",
"net",
Expand Down
3 changes: 2 additions & 1 deletion utxo_verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ edition = "2024"

[dependencies]
accumulator = { path = "../accumulator/" }
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2b07f59545de16b66b3bf8ee988757c2d0c14afb" }
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = true, rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }
peers = { path = "../peers/", default-features = false }
p2p = { path = "../p2p/", package = "swiftsync-p2p", default-features = false }
p2p-messages = { package = "bitcoin-p2p-messages", git = "https://github.com/rust-bitcoin/rust-bitcoin", rev = "2bb9bb6bc99ba07ed3d543a512ec3d2a9462770d" }
tracing = "0.1"
tracing-subscriber = "0.3"
rusqlite = { version = "0.36.0", features = ["bundled"] }
10 changes: 5 additions & 5 deletions utxo_verifier/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ use std::{

use bitcoin::{
BlockHash, OutPoint,
p2p::{
ServiceFlags,
message::{InventoryPayload, NetworkMessage},
message_blockdata::Inventory,
},
script::ScriptExt,
secp256k1::rand::{seq::IteratorRandom, thread_rng},
transaction::TransactionExt,
Expand All @@ -20,6 +15,11 @@ use p2p::{
ConnectionBuilder,
net::{ConnectionExt, ReadExt, WriteExt},
};
use p2p_messages::{
ServiceFlags,
message::{InventoryPayload, NetworkMessage},
message_blockdata::Inventory,
};
use peers::PortExt;

use crate::{AccumulatorUpdate, NETWORK};
Expand Down
Loading