Skip to content

Commit a7bc496

Browse files
committed
Only listen to faucet chain; not other chains in wallet.
1 parent 7130d53 commit a7bc496

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

linera-client/src/chain_listener.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ impl<C: ClientContext> ChainListener<C> {
124124
}
125125

126126
/// Runs the chain listener.
127-
pub async fn run(self) {
128-
let chain_ids = {
127+
///
128+
/// Starts listening to all chains in the wallet, or the given ones, if specified.
129+
pub async fn run(self, chain_ids: Option<Vec<ChainId>>) {
130+
let chain_ids = if let Some(chain_ids) = chain_ids {
131+
BTreeSet::from_iter(chain_ids)
132+
} else {
129133
let guard = self.context.lock().await;
130134
let mut chain_ids = BTreeSet::from_iter(guard.wallet().chain_ids());
131135
chain_ids.insert(guard.wallet().genesis_admin_chain());

linera-client/src/unit_tests/chain_listener.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ async fn test_chain_listener() -> anyhow::Result<()> {
148148
.await?;
149149
let context = Arc::new(Mutex::new(context));
150150
let listener = ChainListener::new(config, context, storage);
151-
listener.run().await;
151+
listener.run(None).await;
152152

153153
// Transfer ownership of chain 0 to the chain listener and some other key. The listener will
154154
// be leader in ~10% of the rounds.

linera-faucet/server/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,12 @@ where
377377
info!("GraphiQL IDE: http://localhost:{}", port);
378378

379379
let context = Arc::clone(&self.context);
380+
let chain_ids = vec![
381+
context.lock().await.wallet().genesis_admin_chain(),
382+
self.main_chain_id,
383+
];
380384
let listener = ChainListener::new(self.config.clone(), context, self.storage.clone());
381-
listener.run().await;
385+
listener.run(Some(chain_ids)).await;
382386

383387
axum::serve(
384388
tokio::net::TcpListener::bind(SocketAddr::from(([0, 0, 0, 0], port))).await?,

linera-service/src/node_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ where
844844

845845
info!("GraphiQL IDE: http://localhost:{}", port);
846846
ChainListener::new(self.config, Arc::clone(&self.context), self.storage.clone())
847-
.run()
847+
.run(None)
848848
.await;
849849
let serve_fut = axum::serve(
850850
tokio::net::TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], port))).await?,

0 commit comments

Comments
 (0)