Skip to content

Commit cfb39a5

Browse files
committed
requested changes
1 parent b22c5b8 commit cfb39a5

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

primitives/src/balances_map.rs

-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ impl<K: Ord, V> Map<K, V> {
7171
pub fn is_empty(&self) -> bool {
7272
self.0.is_empty()
7373
}
74-
75-
pub fn remove(&mut self, key: &K) -> Option<V> {
76-
self.0.remove(key)
77-
}
7874
}
7975

8076
impl<K: Ord, V> FromIterator<(K, V)> for Map<K, V> {

primitives/src/spender.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
use crate::{Address, Channel, Deposit, UnifiedNum};
22
use serde::{Deserialize, Serialize};
33

4-
// #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
5-
// #[serde(rename_all = "camelCase")]
6-
// pub struct SpenderLeaf {
7-
// pub total_spent: UnifiedNum,
8-
// // merkle_proof: [u8; 32], // TODO
9-
// }
10-
114
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
5+
#[serde(rename_all = "camelCase")]
126
pub struct Spender {
137
pub total_deposited: UnifiedNum,
148
pub total_spent: Option<UnifiedNum>,

sentry/src/routes/channel.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,16 @@ pub async fn get_spender_limits<A: Adapter + 'static>(
235235
}
236236
};
237237

238-
let mut new_state = match get_corresponding_new_state(&app.pool, &app.logger, &channel).await? {
238+
let new_state = match get_corresponding_new_state(&app.pool, &app.logger, &channel).await? {
239239
Some(new_state) => new_state,
240240
None => return spender_response_without_leaf(latest_spendable.deposit.total),
241241
};
242242

243-
let total_spent = new_state.balances.spenders.remove(&spender);
243+
let total_spent = new_state
244+
.balances
245+
.spenders
246+
.get(&spender)
247+
.map(|spent| spent.to_owned());
244248

245249
// returned output
246250
let res = SpenderResponse {

0 commit comments

Comments
 (0)