Skip to content

Commit 4253666

Browse files
Corrections for the clone operations. (#4368)
## Motivation Some clone operations no longer need to have an error type. This simplifies the code. ## Proposal Straightforward. ## Test Plan The CI. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links None
1 parent 7b67eec commit 4253666

File tree

6 files changed

+21
-24
lines changed

6 files changed

+21
-24
lines changed

linera-service/src/exporter/runloops/block_processor/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ mod test {
192192
NodeOptions::default(),
193193
0,
194194
signal.clone(),
195-
exporter_storage.clone().unwrap(),
195+
exporter_storage.clone(),
196196
vec![],
197197
);
198198
let mut block_processor = BlockProcessor::new(
@@ -328,7 +328,7 @@ mod test {
328328
NodeOptions::default(),
329329
0,
330330
signal.clone(),
331-
exporter_storage.clone().unwrap(),
331+
exporter_storage.clone(),
332332
vec![],
333333
);
334334
let mut block_processor = BlockProcessor::new(
@@ -444,7 +444,7 @@ mod test {
444444
NodeOptions::default(),
445445
0,
446446
signal.clone(),
447-
exporter_storage.clone().unwrap(),
447+
exporter_storage.clone(),
448448
vec![],
449449
);
450450
let mut block_processor = BlockProcessor::new(
@@ -531,7 +531,7 @@ mod test {
531531
NodeOptions::default(),
532532
0,
533533
signal.clone(),
534-
exporter_storage.clone().unwrap(),
534+
exporter_storage.clone(),
535535
vec![],
536536
);
537537
let mut block_processor = BlockProcessor::new(
@@ -640,7 +640,7 @@ mod test {
640640
NodeOptions::default(),
641641
0,
642642
signal.clone(),
643-
exporter_storage.clone().unwrap(),
643+
exporter_storage.clone(),
644644
vec![],
645645
);
646646
let mut block_processor = BlockProcessor::new(

linera-service/src/exporter/runloops/indexer/indexer_exporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Exporter {
6868
self.work_queue_size,
6969
destination_state.load(Ordering::Acquire) as usize,
7070
outgoing_stream,
71-
storage.clone().unwrap(),
71+
storage.clone(),
7272
);
7373

7474
let mut acknowledgement_task =

linera-service/src/exporter/runloops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ where
112112
options,
113113
limits.work_queue_size.into(),
114114
shutdown_signal.clone(),
115-
exporter_storage.clone().unwrap(),
115+
exporter_storage.clone(),
116116
destination_config.destinations.clone(),
117117
);
118118

linera-service/src/exporter/runloops/task_manager.rs

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

113113
fn spawn(&mut self, id: DestinationId) {
114114
let exporter_builder = &self.exporters_builder;
115-
let join_handle = exporter_builder.spawn(id.clone(), self.storage.clone().unwrap());
115+
let join_handle = exporter_builder.spawn(id.clone(), self.storage.clone());
116116
self.join_handles.insert(id, join_handle);
117117
}
118118
}

linera-service/src/exporter/runloops/validator_exporter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ impl Exporter {
6262
let (mut task_queue, task_receiver) = TaskQueue::new(
6363
self.work_queue_size,
6464
destination_state.load(Ordering::Acquire) as usize,
65-
storage.clone().unwrap(),
65+
storage.clone(),
6666
);
6767

68-
let export_task = ExportTask::new(node, storage.clone().unwrap(), destination_state);
68+
let export_task = ExportTask::new(node, storage.clone(), destination_state);
6969

7070
tokio::select! {
7171

linera-service/src/exporter/storage.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ use linera_base::{
1717
identifiers::{BlobId, ChainId},
1818
};
1919
use linera_chain::types::ConfirmedBlockCertificate;
20-
use linera_sdk::{
21-
ensure,
22-
views::{View, ViewError},
23-
};
20+
use linera_sdk::{ensure, views::View};
2421
use linera_service::config::{DestinationId, LimitsConfig};
2522
use linera_storage::Storage;
2623
use linera_views::{
@@ -146,14 +143,14 @@ where
146143
self.shared_canonical_state.push(block)
147144
}
148145

149-
fn clone(&mut self) -> Result<Self, ExporterError> {
150-
Ok(Self {
146+
fn clone(&mut self) -> Self {
147+
Self {
151148
storage: self.storage.clone(),
152-
shared_canonical_state: self.shared_canonical_state.clone()?,
149+
shared_canonical_state: self.shared_canonical_state.clone(),
153150
blobs_cache: self.blobs_cache.clone(),
154151
blocks_cache: self.blocks_cache.clone(),
155152
destination_states: self.destination_states.clone(),
156-
})
153+
}
157154
}
158155
}
159156

@@ -206,8 +203,8 @@ where
206203
self.shared_storage.destination_states.load_state(id)
207204
}
208205

209-
pub(crate) fn clone(&mut self) -> Result<Self, ExporterError> {
210-
Ok(ExporterStorage::new(self.shared_storage.clone()?))
206+
pub(crate) fn clone(&mut self) -> Self {
207+
ExporterStorage::new(self.shared_storage.clone())
211208
}
212209

213210
pub(crate) fn get_latest_index(&self) -> usize {
@@ -244,7 +241,7 @@ where
244241

245242
let mut shared_storage =
246243
SharedStorage::new(storage, canonical_state, destination_states, limits);
247-
let exporter_storage = ExporterStorage::new(shared_storage.clone()?);
244+
let exporter_storage = ExporterStorage::new(shared_storage.clone());
248245

249246
Ok((
250247
Self {
@@ -426,13 +423,13 @@ where
426423
}
427424
}
428425

429-
fn clone(&mut self) -> Result<Self, ViewError> {
430-
Ok(Self {
426+
fn clone(&mut self) -> Self {
427+
Self {
431428
count: self.count,
432429
state_cache: self.state_cache.clone(),
433430
state_updates_buffer: self.state_updates_buffer.clone(),
434431
state_context: self.state_context.clone_unchecked(),
435-
})
432+
}
436433
}
437434

438435
/// Returns the latest index of the canonical state.

0 commit comments

Comments
 (0)