Fix session drop
This commit is contained in:
committed by
Tyera Eulberg
parent
537436bd5e
commit
7424388924
14
src/rpc.rs
14
src/rpc.rs
@@ -536,20 +536,6 @@ mod tests {
|
||||
assert_eq!(expected, result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rpc_start_sub_channel() {
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let (io, meta, _last_id, _alice_keypair) = start_rpc_handler_with_tx(bob_pubkey);
|
||||
|
||||
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"startSubscriptionChannel"}}"#);
|
||||
let res = io.handle_request_sync(&req, meta);
|
||||
let json: Value = serde_json::from_str(&res.expect("actual response"))
|
||||
.expect("actual response deserialization");
|
||||
let port = json["result"]["port"].as_u64().unwrap();
|
||||
assert!(8000 <= port && port < 10000);
|
||||
assert!(json["result"]["path"].is_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rpc_send_tx() {
|
||||
let leader_keypair = Keypair::new();
|
||||
|
@@ -51,16 +51,6 @@ impl PubSubService {
|
||||
let session = Arc::new(Session::new(context.sender().clone()));
|
||||
session.on_drop(Box::new(|| {
|
||||
info!("Pubsub connection dropped");
|
||||
// Following should not be required as jsonrpc_pubsub will
|
||||
// unsubscribe automatically once the websocket is dropped ...
|
||||
/*
|
||||
for (_, (bank_sub_id, pubkey)) in self.account_subscriptions.read().unwrap().iter() {
|
||||
server_bank.remove_account_subscription(bank_sub_id, pubkey);
|
||||
}
|
||||
for (_, (bank_sub_id, signature)) in self.signature_subscriptions.read().unwrap().iter() {
|
||||
server_bank.remove_signature_subscription(bank_sub_id, signature);
|
||||
}
|
||||
*/
|
||||
}));
|
||||
session
|
||||
})
|
||||
@@ -93,7 +83,7 @@ build_rpc_trait! {
|
||||
|
||||
// Unsubscribe from account notification subscription.
|
||||
#[rpc(name = "accountUnsubscribe")]
|
||||
fn account_unsubscribe(&self, Self::Metadata, SubscriptionId) -> Result<bool>;
|
||||
fn account_unsubscribe(&self, SubscriptionId) -> Result<bool>;
|
||||
}
|
||||
#[pubsub(name = "signatureNotification")] {
|
||||
// Get notification when signature is verified
|
||||
@@ -103,7 +93,7 @@ build_rpc_trait! {
|
||||
|
||||
// Unsubscribe from signature notification subscription.
|
||||
#[rpc(name = "signatureUnsubscribe")]
|
||||
fn signature_unsubscribe(&self, Self::Metadata, SubscriptionId) -> Result<bool>;
|
||||
fn signature_unsubscribe(&self, SubscriptionId) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +153,7 @@ impl RpcSolPubSub for RpcSolPubSubImpl {
|
||||
.add_account_subscription(bank_sub_id, pubkey, sink);
|
||||
}
|
||||
|
||||
fn account_unsubscribe(&self, _meta: Self::Metadata, id: SubscriptionId) -> Result<bool> {
|
||||
fn account_unsubscribe(&self, id: SubscriptionId) -> Result<bool> {
|
||||
info!("account_unsubscribe");
|
||||
if let Some((bank_sub_id, pubkey)) = self.account_subscriptions.write().unwrap().remove(&id)
|
||||
{
|
||||
@@ -223,7 +213,7 @@ impl RpcSolPubSub for RpcSolPubSubImpl {
|
||||
}
|
||||
}
|
||||
|
||||
fn signature_unsubscribe(&self, _meta: Self::Metadata, id: SubscriptionId) -> Result<bool> {
|
||||
fn signature_unsubscribe(&self, id: SubscriptionId) -> Result<bool> {
|
||||
info!("signature_unsubscribe");
|
||||
if let Some((bank_sub_id, signature)) =
|
||||
self.signature_subscriptions.write().unwrap().remove(&id)
|
||||
|
Reference in New Issue
Block a user