mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-29 03:21:33 +03:00
hotfix: make sub ids unique in eth provider
This commit is contained in:
parent
23ed84de4a
commit
7d01dcfcae
@ -118,6 +118,7 @@ async fn handle_request(
|
||||
) -> Result<(), EthError> {
|
||||
match action {
|
||||
EthAction::SubscribeLogs { sub_id, filter } => {
|
||||
let sub_id = (target.process.clone(), sub_id);
|
||||
if connections.ws_provider_subscriptions.contains_key(&sub_id) {
|
||||
return Err(EthError::SubscriptionIdCollision);
|
||||
}
|
||||
@ -133,6 +134,7 @@ async fn handle_request(
|
||||
Ok(())
|
||||
}
|
||||
EthAction::UnsubscribeLogs(sub_id) => {
|
||||
let sub_id = (target.process.clone(), sub_id);
|
||||
let handle = connections
|
||||
.ws_provider_subscriptions
|
||||
.remove(&sub_id)
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::types::ProcessId;
|
||||
use ethers::prelude::Provider;
|
||||
use ethers::types::{Filter, Log};
|
||||
use ethers_providers::Ws;
|
||||
@ -48,5 +49,5 @@ pub enum EthSubEvent {
|
||||
/// Primary state object of the `eth` module
|
||||
pub struct RpcConnections {
|
||||
pub provider: Provider<Ws>,
|
||||
pub ws_provider_subscriptions: HashMap<u64, JoinHandle<Result<(), EthError>>>,
|
||||
pub ws_provider_subscriptions: HashMap<(ProcessId, u64), JoinHandle<Result<(), EthError>>>,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user