-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RPC: Fix eth subscription notifications (#2812)
* Enable passing null value in topic list in subscriptions RPC * Revamp subscription pipeline, use tokio multithread runtime * Better refactor * Fmt rs * Add config to start up notification RPC, defaults to false * Revert default subscription service to startup
- Loading branch information
Showing
17 changed files
with
270 additions
and
276 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::Result; | ||
use ethereum_types::H256; | ||
use tokio::sync::broadcast::{self, Sender}; | ||
|
||
pub const NOTIFICATION_CHANNEL_BUFFER_SIZE: usize = 10_000; | ||
|
||
#[derive(Clone)] | ||
pub enum Notification { | ||
Block(H256), | ||
Transaction(H256), | ||
} | ||
|
||
pub struct SubscriptionService { | ||
pub tx: Sender<Notification>, | ||
} | ||
|
||
impl SubscriptionService { | ||
pub fn new() -> Self { | ||
let (tx, _rx) = | ||
broadcast::channel(ain_cpp_imports::get_evm_notification_channel_buffer_size()); | ||
Self { tx } | ||
} | ||
|
||
pub fn send(&self, notification: Notification) -> Result<()> { | ||
// Do not need to handle send error since there may be no active receivers. | ||
let _ = self.tx.send(notification); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Default for SubscriptionService { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.