Skip to content

Commit e1bb7df

Browse files
authored
Remove Client::clone_with. (#3747)
## Motivation `Client::clone_with` creates a clone with a different set of tracked chains. This is used when downloading a new chain's parent chain. But it's not actually necessary, since we want to track the new chain anyway, and it suffices to track the child, not the parent, to make sure the `OpenChain` message is handled. ## Proposal Remove `clone_with`; directly add the child to the tracked chains. ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent bb0e3ed commit e1bb7df

File tree

2 files changed

+9
-44
lines changed

2 files changed

+9
-44
lines changed

linera-client/src/client_context.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,7 @@ where
402402
S: Storage + Clone + Send + Sync + 'static,
403403
{
404404
let node_provider = self.make_node_provider();
405-
let client = self.client.clone_with(
406-
node_provider.clone(),
407-
"Temporary client for fetching the parent chain",
408-
vec![message_id.chain_id, chain_id],
409-
false,
410-
);
405+
self.client.track_chain(chain_id);
411406

412407
// Take the latest committee we know of.
413408
let admin_chain_id = self.wallet.genesis_admin_chain();
@@ -418,7 +413,11 @@ where
418413
.map(|(public_key, node)| RemoteNode { public_key, node })
419414
.collect()
420415
} else {
421-
let info = client.local_node().handle_chain_info_query(query).await?;
416+
let info = self
417+
.client
418+
.local_node()
419+
.handle_chain_info_query(query)
420+
.await?;
422421
let committee = info
423422
.latest_committee()
424423
.ok_or(error::Inner::ChainInfoResponseMissingCommittee)?;
@@ -430,13 +429,14 @@ where
430429

431430
// Download the parent chain.
432431
let target_height = message_id.height.try_add_one()?;
433-
client
432+
self.client
434433
.download_certificates(&nodes, message_id.chain_id, target_height)
435434
.await
436435
.context("downloading parent chain")?;
437436

438437
// The initial timestamp for the new chain is taken from the block with the message.
439-
let certificate = client
438+
let certificate = self
439+
.client
440440
.local_node()
441441
.certificate_for(&message_id)
442442
.await

linera-core/src/client/mod.rs

-35
Original file line numberDiff line numberDiff line change
@@ -221,41 +221,6 @@ impl<P, S: Storage + Clone> Client<P, S> {
221221
}
222222
}
223223

224-
/// Returns a clone with a different set of tracked chains.
225-
pub fn clone_with(
226-
&self,
227-
validator_node_provider: P,
228-
name: impl Into<String>,
229-
tracked_chains: impl IntoIterator<Item = ChainId>,
230-
long_lived_services: bool,
231-
) -> Self {
232-
let tracked_chains = Arc::new(RwLock::new(tracked_chains.into_iter().collect()));
233-
let state = WorkerState::new_for_client(
234-
name.into(),
235-
self.storage.clone(),
236-
tracked_chains.clone(),
237-
self.max_loaded_chains,
238-
)
239-
.with_long_lived_services(long_lived_services)
240-
.with_allow_inactive_chains(true)
241-
.with_allow_messages_from_deprecated_epochs(true);
242-
let local_node = LocalNodeClient::new(state);
243-
Self {
244-
validator_node_provider,
245-
local_node,
246-
chains: DashMap::new(),
247-
max_pending_message_bundles: self.max_pending_message_bundles,
248-
message_policy: MessagePolicy::new(BlanketMessagePolicy::Accept, None),
249-
cross_chain_message_delivery: self.cross_chain_message_delivery,
250-
grace_period: self.grace_period,
251-
tracked_chains,
252-
notifier: Arc::new(ChannelNotifier::default()),
253-
storage: self.storage.clone(),
254-
max_loaded_chains: self.max_loaded_chains,
255-
blob_download_timeout: self.blob_download_timeout,
256-
}
257-
}
258-
259224
/// Returns the storage client used by this client's local node.
260225
#[instrument(level = "trace", skip(self))]
261226
pub fn storage_client(&self) -> &S {

0 commit comments

Comments
 (0)