Skip to content

Commit

Permalink
refactor: remove fake failure mode from function
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Dec 5, 2023
1 parent 63a9563 commit 124960c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion sn_node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ impl Node {
.map_err(|_| ProtocolError::GetStoreCostFailed);

QueryResponse::GetStoreCost {
quote: Self::create_quote_for_storecost(network, store_cost, &address),
quote: store_cost.and_then(|cost| {
Self::create_quote_for_storecost(network, cost, &address)
}),
payment_address,
}
}
Expand Down
8 changes: 3 additions & 5 deletions sn_node/src/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ const QUOTE_EXPIRATION_SECS: u64 = 3600;
impl Node {
pub(crate) fn create_quote_for_storecost(
network: &Network,
store_cost: Result<NanoTokens, ProtocolError>,
cost: NanoTokens,
address: &NetworkAddress,
) -> Result<PaymentQuote, ProtocolError> {
let cost = store_cost?;
let content = address.as_xorname().unwrap_or_default();
let timestamp = std::time::SystemTime::now();
let bytes = PaymentQuote::bytes_for_signing(content, cost, timestamp);

let signature = match network.sign(&bytes) {
Ok(s) => s,
Err(_) => return Err(ProtocolError::QuoteGenerationFailed),
let Ok(signature) = network.sign(&bytes) else {
return Err(ProtocolError::QuoteGenerationFailed);
};

let quote = PaymentQuote {
Expand Down

0 comments on commit 124960c

Please sign in to comment.