fc_rpc_core/
eth_pubsub.rs

1// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
2// This file is part of Frontier.
3//
4// Copyright (c) 2015-2020 Parity Technologies (UK) Ltd.
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Eth PUB-SUB rpc interface.
20
21use jsonrpc_core::Result;
22use jsonrpc_derive::rpc;
23use jsonrpc_pubsub::{typed, SubscriptionId};
24
25use crate::types::pubsub;
26
27pub use rpc_impl_EthPubSubApi::gen_server::EthPubSubApi as EthPubSubApiServer;
28
29/// Eth PUB-SUB rpc interface.
30#[rpc(server)]
31pub trait EthPubSubApi {
32	/// RPC Metadata
33	type Metadata;
34
35	/// Subscribe to Eth subscription.
36	#[pubsub(subscription = "eth_subscription", subscribe, name = "eth_subscribe")]
37	fn subscribe(
38		&self,
39		_: Self::Metadata,
40		_: typed::Subscriber<pubsub::Result>,
41		_: pubsub::Kind,
42		_: Option<pubsub::Params>,
43	);
44
45	/// Unsubscribe from existing Eth subscription.
46	#[pubsub(subscription = "eth_subscription", unsubscribe, name = "eth_unsubscribe")]
47	fn unsubscribe(&self, _: Option<Self::Metadata>, _: SubscriptionId) -> Result<bool>;
48}