Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove NetworkSpecialization::on_event #3976

Merged
merged 1 commit into from
Oct 31, 2019
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: 0 additions & 4 deletions core/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,6 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
self.context_data.peers.iter().map(|(id, peer)| (id, &peer.info))
}

pub fn on_event(&mut self, event: Event) {
self.specialization.on_event(event);
}

pub fn on_custom_message(
&mut self,
who: PeerId,
Expand Down
3 changes: 2 additions & 1 deletion core/network/src/protocol/specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
);

/// Called when a network-specific event arrives.
fn on_event(&mut self, event: Event);
#[deprecated(note = "This method is never called; please use `with_dht_event_tx` when building the service")]
fn on_event(&mut self, event: Event) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove it completely? We don't have anything that uses it and we don't have anything released. Deprecating does not makes any sense here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there's Polkadot. The idea was to then make a Polkadot PR, then later actually remove them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure. It is not that something updates Polkadot automatically. You could already open the pr to Polkadot and everybody would be happy.


/// Called on abort.
#[deprecated(note = "This method is never called; aborting corresponds to dropping the object")]
Expand Down
16 changes: 6 additions & 10 deletions core/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkServic

/// Start getting a value from the DHT.
///
/// This will generate either a `ValueFound` or a `ValueNotFound` event and pass it to
/// `on_event` on the network specialization.
/// This will generate either a `ValueFound` or a `ValueNotFound` event and pass it as an
/// item on the [`NetworkWorker`] stream.
pub fn get_value(&self, key: &record::Key) {
let _ = self
.to_worker
Expand All @@ -490,8 +490,8 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkServic

/// Start putting a value in the DHT.
///
/// This will generate either a `ValuePut` or a `ValuePutFailed` event and pass it to
/// `on_event` on the network specialization.
/// This will generate either a `ValuePut` or a `ValuePutFailed` event and pass it as an
/// item on the [`NetworkWorker`] stream.
pub fn put_value(&self, key: record::Key, value: Vec<u8>) {
let _ = self
.to_worker
Expand Down Expand Up @@ -718,12 +718,8 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> Stream for Ne
let outcome = match poll_value {
Ok(Async::NotReady) => break,
Ok(Async::Ready(Some(BehaviourOut::SubstrateAction(outcome)))) => outcome,
Ok(Async::Ready(Some(BehaviourOut::Dht(ev)))) => {
self.network_service.user_protocol_mut()
.on_event(Event::Dht(ev.clone()));

return Ok(Async::Ready(Some(Event::Dht(ev))));
},
Ok(Async::Ready(Some(BehaviourOut::Dht(ev)))) =>
return Ok(Async::Ready(Some(Event::Dht(ev)))),
Ok(Async::Ready(None)) => CustomMessageOutcome::None,
Err(err) => {
error!(target: "sync", "Error in the network: {:?}", err);
Expand Down
5 changes: 0 additions & 5 deletions core/network/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ impl NetworkSpecialization<Block> for DummySpecialization {
_peer_id: PeerId,
_message: Vec<u8>,
) {}

fn on_event(
&mut self,
_event: crate::specialization::Event
) {}
}

pub type PeersFullClient =
Expand Down