aboutsummaryrefslogtreecommitdiff
path: root/src/model/block.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-03 13:58:05 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:52:46 +0100
commitbeeef4758e5ec0d521179a799a3237c2c0368911 (patch)
treeeb2734647b3c6e62cef64a5f2b533ac694252c29 /src/model/block.rs
parentd8ab5bdc3e20759e5ba8a6844393757da3539372 (diff)
downloadgarage-beeef4758e5ec0d521179a799a3237c2c0368911.tar.gz
garage-beeef4758e5ec0d521179a799a3237c2c0368911.zip
Some movement of helper code and refactoring of error handling
Diffstat (limited to 'src/model/block.rs')
-rw-r--r--src/model/block.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/model/block.rs b/src/model/block.rs
index 6df8e265..1173c7b3 100644
--- a/src/model/block.rs
+++ b/src/model/block.rs
@@ -594,10 +594,8 @@ impl BlockManager {
need_nodes.push(*node);
}
}
- _ => {
- return Err(Error::Message(
- "Unexpected response to NeedBlockQuery RPC".to_string(),
- ));
+ m => {
+ return Err(Error::unexpected_rpc_message(m));
}
}
}
@@ -730,7 +728,7 @@ impl EndpointHandler<BlockRpc> for BlockManager {
BlockRpc::PutBlock { hash, data } => self.write_block(hash, data).await,
BlockRpc::GetBlock(h) => self.read_block(h).await,
BlockRpc::NeedBlockQuery(h) => self.need_block(h).await.map(BlockRpc::NeedBlockReply),
- _ => Err(Error::BadRpc("Unexpected RPC message".to_string())),
+ m => Err(Error::unexpected_rpc_message(m)),
}
}
}