blob: 2cb1bdda4b6dcfbb771d186775e300a39d64e191 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# req-030
Schist must implement the procedure described below as `calculate_bucket_balance`.
## calculate_bucket_balance
Inputs:
- A bucket name, `name`
1. If no bucket exists with the name, `name`, then return empty.
2. If more than one bucket exists with the name, `name`, then panic.
3. Let `bucket` be the bucket with the given name.
4. Let `cache_key = bucket.balance_cache_key`.
5. Let `is_up_to_date` be the result of the procedure,
`is_bucket_balance_up_to_date(bucket)`, as described in req-035.
6. If `is_up_to_date = TRUE`, then return `bucket.balance`.
7. Let `transaction_sum` be the sum over the property, `amount`, of all
transactions `t` such that `t.bucket_id = bucket.id`.
8. Let `drip_sum` be the sum over the property, `amount`, of all drips `d` such
that `d.bucket_id = bucket.id`.
9. Return `drip_sum - transaction_sum`.
Source: req-029
|