Skip to content
Open
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
1 change: 1 addition & 0 deletions Untitled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alloy-provider
3 changes: 3 additions & 0 deletions crates/net/network-api/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ pub trait EthWireProvider<N: NetworkPrimitives> {

/// 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);
}
9 changes: 9 additions & 0 deletions crates/net/network-api/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ impl<N: NetworkPrimitives> EthWireProvider<N> for NoopNetwork<N> {
) {
unreachable!()
}

fn eth_wire_announce_block_to(
&self,
_peer_id: PeerId,
_block: <N as NetworkPrimitives>::NewBlockPayload,
_hash: alloy_primitives::B256,
) {
unreachable!()
}
}

impl<Net> NetworkPeersEvents for NoopNetwork<Net>
Expand Down
13 changes: 11 additions & 2 deletions crates/net/network/src/network.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -237,6 +241,11 @@ impl<N: NetworkPrimitives> EthWireProvider<N> for NetworkHandle<N> {
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<N: NetworkPrimitives> NetworkProtocols for NetworkHandle<N> {
Expand Down
Loading