diff --git a/Untitled b/Untitled new file mode 100644 index 00000000000..08cad252e9d --- /dev/null +++ b/Untitled @@ -0,0 +1 @@ +alloy-provider \ No newline at end of file diff --git a/crates/net/network-api/src/block.rs b/crates/net/network-api/src/block.rs index 994c90a09a8..fffe5091e4e 100644 --- a/crates/net/network-api/src/block.rs +++ b/crates/net/network-api/src/block.rs @@ -23,4 +23,7 @@ pub trait EthWireProvider { /// Announce a new block to the network over the eth wire protocol. fn eth_wire_announce_block(&self, block: N::NewBlockPayload, hash: B256); + + /// Announce a new block to a specific peer over the eth wire protocol. + fn eth_wire_announce_block_to(&self, peer_id: PeerId, block: N::NewBlockPayload, hash: B256); } diff --git a/crates/net/network-api/src/noop.rs b/crates/net/network-api/src/noop.rs index a40f21270a9..8d18a339572 100644 --- a/crates/net/network-api/src/noop.rs +++ b/crates/net/network-api/src/noop.rs @@ -223,6 +223,15 @@ impl EthWireProvider for NoopNetwork { ) { unreachable!() } + + fn eth_wire_announce_block_to( + &self, + _peer_id: PeerId, + _block: ::NewBlockPayload, + _hash: alloy_primitives::B256, + ) { + unreachable!() + } } impl NetworkPeersEvents for NoopNetwork diff --git a/crates/net/network/src/network.rs b/crates/net/network/src/network.rs index 9e01cff13ae..ef87b7c1022 100644 --- a/crates/net/network/src/network.rs +++ b/crates/net/network/src/network.rs @@ -1,6 +1,10 @@ use crate::{ - config::NetworkMode, message::PeerMessage, protocol::RlpxSubProtocol, - swarm::NetworkConnectionState, transactions::TransactionsHandle, FetchClient, + config::NetworkMode, + message::{NewBlockMessage, PeerMessage}, + protocol::RlpxSubProtocol, + swarm::NetworkConnectionState, + transactions::TransactionsHandle, + FetchClient, }; use alloy_primitives::B256; use enr::Enr; @@ -237,6 +241,11 @@ impl EthWireProvider for NetworkHandle { fn eth_wire_announce_block(&self, block: N::NewBlockPayload, hash: B256) { self.announce_block(block, hash) } + + fn eth_wire_announce_block_to(&self, peer_id: PeerId, block: N::NewBlockPayload, hash: B256) { + let msg = NewBlockMessage { hash, block: Arc::new(block) }; + self.send_eth_message(peer_id, PeerMessage::NewBlock(msg)) + } } impl NetworkProtocols for NetworkHandle {