aboutsummaryrefslogtreecommitdiff
path: root/src/block.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-21 17:08:42 +0000
committerAlex Auvolat <alex@adnab.me>2020-04-21 17:08:42 +0000
commitec59e896c6cf405a0e52392ebb8619f26a367968 (patch)
tree4065518f40a7aa40a6c13506be43706061e795e8 /src/block.rs
parent8915224966e41195bd5844d9df29a3f0c7d7d6ae (diff)
downloadgarage-ec59e896c6cf405a0e52392ebb8619f26a367968.tar.gz
garage-ec59e896c6cf405a0e52392ebb8619f26a367968.zip
Make UUID & Hash Copy and remove some .clone() noise
Diffstat (limited to 'src/block.rs')
-rw-r--r--src/block.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/block.rs b/src/block.rs
index ec29db12..46abcf02 100644
--- a/src/block.rs
+++ b/src/block.rs
@@ -156,13 +156,10 @@ impl BlockManager {
warn!("Block {:?} is corrupted. Deleting and resyncing.", hash);
fs::remove_file(path).await?;
self.put_to_resync(&hash, 0)?;
- return Err(Error::CorruptData(hash.clone()));
+ return Err(Error::CorruptData(*hash));
}
- Ok(Message::PutBlock(PutBlockMessage {
- hash: hash.clone(),
- data,
- }))
+ Ok(Message::PutBlock(PutBlockMessage { hash: *hash, data }))
}
pub async fn need_block(&self, hash: &Hash) -> Result<bool, Error> {
@@ -273,7 +270,7 @@ impl BlockManager {
if needed_by_others {
let ring = garage.system.ring.borrow().clone();
let who = ring.walk_ring(&hash, garage.system.config.data_replication_factor);
- let msg = Arc::new(Message::NeedBlockQuery(hash.clone()));
+ let msg = Arc::new(Message::NeedBlockQuery(*hash));
let who_needs_fut = who.iter().map(|to| {
self.rpc_client
.call(to, msg.clone(), NEED_BLOCK_QUERY_TIMEOUT)
@@ -329,7 +326,7 @@ impl BlockManager {
pub async fn rpc_get_block(&self, hash: &Hash) -> Result<Vec<u8>, Error> {
let ring = self.system.ring.borrow().clone();
let who = ring.walk_ring(&hash, self.system.config.data_replication_factor);
- let msg = Arc::new(Message::GetBlock(hash.clone()));
+ let msg = Arc::new(Message::GetBlock(*hash));
let mut resp_stream = who
.iter()
.map(|to| self.rpc_client.call(to, msg.clone(), BLOCK_RW_TIMEOUT))
@@ -374,7 +371,7 @@ impl BlockManager {
continue;
}
if !block_ref.deleted {
- last_hash = Some(block_ref.block.clone());
+ last_hash = Some(block_ref.block);
self.put_to_resync(&block_ref.block, 0)?;
}
i += 1;