Skip to content

Commit

Permalink
fix SubscriptionRpc
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Dec 12, 2023
1 parent f9c0092 commit 6868b40
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion rpc/src/module/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ impl SubscriptionRpc for SubscriptionRpcImpl {
Topic::ProposedTransaction => self.proposed_transaction_sender.clone(),
Topic::RejectedTransaction => self.new_reject_transaction_sender.clone(),
};
let mut rx = tx.subscribe();
Ok(Box::pin(async_stream::stream! {
while let Ok(msg) = tx.subscribe().recv().await {
while let Ok(msg) = rx.recv().await {
yield msg;
}
}))
Expand Down
9 changes: 3 additions & 6 deletions rpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ impl RpcServer {
stream_config
.with_keep_alive(true)
.with_shutdown(async move {
let exit = new_tokio_exit_rx();
exit.cancelled().await;
new_tokio_exit_rx().cancelled().await;
});
app = app.layer(Extension(ws_config));
}
Expand All @@ -121,8 +120,7 @@ impl RpcServer {

let _ = tx_addr.send(server.local_addr());
let graceful = server.with_graceful_shutdown(async move {
let exit = new_tokio_exit_rx();
exit.cancelled().await;
new_tokio_exit_rx().cancelled().await;
});
drop(graceful.await);
});
Expand All @@ -144,8 +142,7 @@ impl RpcServer {
.with_channel_size(4)
.with_pipeline_size(4)
.with_shutdown(async move {
let exit = new_tokio_exit_rx();
exit.cancelled().await;
new_tokio_exit_rx().cancelled().await;
});

let exit_signal: CancellationToken = new_tokio_exit_rx();
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/service_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'a> ServiceBuilder<'a> {
pub fn new(config: &'a RpcConfig) -> Self {
Self {
config,
io_handler: IoHandler::with_compatibility(jsonrpc_core::Compatibility::V2),
io_handler: IoHandler::default(),
}
}

Expand Down
3 changes: 0 additions & 3 deletions rpc/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const CELLBASE_MATURITY: u64 = 0;
const ALERT_UNTIL_TIMESTAMP: u64 = 2_524_579_200;

// Construct `Consensus` with an always-success cell
//
// It is similar to `util::test-chain-utils::always_success_consensus`, but with hard-code
// genesis timestamp.
pub(crate) fn always_success_consensus() -> Consensus {
let always_success_tx = always_success_transaction();
let dao = genesis_dao_data(vec![&always_success_tx]).unwrap();
Expand Down

0 comments on commit 6868b40

Please sign in to comment.