Fix session drop
This commit is contained in:
parent
537436bd5e
commit
7424388924
10
Cargo.toml
10
Cargo.toml
|
@ -80,11 +80,11 @@ env_logger = "0.5.12"
|
||||||
generic-array = { version = "0.12.0", default-features = false, features = ["serde"] }
|
generic-array = { version = "0.12.0", default-features = false, features = ["serde"] }
|
||||||
getopts = "0.2"
|
getopts = "0.2"
|
||||||
influx_db_client = "0.3.4"
|
influx_db_client = "0.3.4"
|
||||||
solana-jsonrpc-core = "0.2.0"
|
solana-jsonrpc-core = "0.3.0"
|
||||||
solana-jsonrpc-http-server = "0.2.0"
|
solana-jsonrpc-http-server = "0.3.0"
|
||||||
solana-jsonrpc-macros = "0.2.0"
|
solana-jsonrpc-macros = "0.3.0"
|
||||||
solana-jsonrpc-pubsub = "0.2.0"
|
solana-jsonrpc-pubsub = "0.3.0"
|
||||||
solana-jsonrpc-ws-server = "0.2.0"
|
solana-jsonrpc-ws-server = "0.3.0"
|
||||||
ipnetwork = "0.12.7"
|
ipnetwork = "0.12.7"
|
||||||
itertools = "0.7.8"
|
itertools = "0.7.8"
|
||||||
libc = "0.2.43"
|
libc = "0.2.43"
|
||||||
|
|
14
src/rpc.rs
14
src/rpc.rs
|
@ -536,20 +536,6 @@ mod tests {
|
||||||
assert_eq!(expected, result);
|
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]
|
#[test]
|
||||||
fn test_rpc_send_tx() {
|
fn test_rpc_send_tx() {
|
||||||
let leader_keypair = Keypair::new();
|
let leader_keypair = Keypair::new();
|
||||||
|
|
|
@ -51,16 +51,6 @@ impl PubSubService {
|
||||||
let session = Arc::new(Session::new(context.sender().clone()));
|
let session = Arc::new(Session::new(context.sender().clone()));
|
||||||
session.on_drop(Box::new(|| {
|
session.on_drop(Box::new(|| {
|
||||||
info!("Pubsub connection dropped");
|
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
|
session
|
||||||
})
|
})
|
||||||
|
@ -93,7 +83,7 @@ build_rpc_trait! {
|
||||||
|
|
||||||
// Unsubscribe from account notification subscription.
|
// Unsubscribe from account notification subscription.
|
||||||
#[rpc(name = "accountUnsubscribe")]
|
#[rpc(name = "accountUnsubscribe")]
|
||||||
fn account_unsubscribe(&self, Self::Metadata, SubscriptionId) -> Result<bool>;
|
fn account_unsubscribe(&self, SubscriptionId) -> Result<bool>;
|
||||||
}
|
}
|
||||||
#[pubsub(name = "signatureNotification")] {
|
#[pubsub(name = "signatureNotification")] {
|
||||||
// Get notification when signature is verified
|
// Get notification when signature is verified
|
||||||
|
@ -103,7 +93,7 @@ build_rpc_trait! {
|
||||||
|
|
||||||
// Unsubscribe from signature notification subscription.
|
// Unsubscribe from signature notification subscription.
|
||||||
#[rpc(name = "signatureUnsubscribe")]
|
#[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);
|
.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");
|
info!("account_unsubscribe");
|
||||||
if let Some((bank_sub_id, pubkey)) = self.account_subscriptions.write().unwrap().remove(&id)
|
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");
|
info!("signature_unsubscribe");
|
||||||
if let Some((bank_sub_id, signature)) =
|
if let Some((bank_sub_id, signature)) =
|
||||||
self.signature_subscriptions.write().unwrap().remove(&id)
|
self.signature_subscriptions.write().unwrap().remove(&id)
|
||||||
|
|
Loading…
Reference in New Issue