diff options
Diffstat (limited to 'src/reducer/anastasis_api_backup_redux.c')
-rw-r--r-- | src/reducer/anastasis_api_backup_redux.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/reducer/anastasis_api_backup_redux.c b/src/reducer/anastasis_api_backup_redux.c index de6537e..d0268c9 100644 --- a/src/reducer/anastasis_api_backup_redux.c +++ b/src/reducer/anastasis_api_backup_redux.c @@ -102,6 +102,26 @@ add_cost (struct Costs **my_cost, } +/** + * Add amount from @a cost to @a my_cost list. + * + * @param[in,out] my_cost pointer to list to modify + * @param cost amount to add + */ +static void +add_costs (struct Costs **my_cost, + const struct Costs *costs) +{ + for (const struct Costs *pos = costs; + NULL != pos; + pos = pos->next) + { + add_cost (my_cost, + &pos->cost); + } +} + + enum ANASTASIS_BackupState ANASTASIS_backup_state_from_string_ (const char *state_string) { @@ -459,7 +479,7 @@ struct PolicyEntry /** * Recovery fee. */ - struct TALER_Amount usage_fee; + struct Costs *usage_fee; }; @@ -907,10 +927,11 @@ eval_provider_selection (struct PolicyBuilder *pb, challenge_size) ) ) { found = true; - GNUNET_break (0 <= - TALER_amount_add (&policy_ent[i].usage_fee, - &method_cost, - &upload_cost)); + + add_cost (&policy_ent[i].usage_fee, + &method_cost); + add_cost (&policy_ent[i].usage_fee, + &upload_cost); } } if (! found) @@ -962,6 +983,8 @@ eval_provider_selection (struct PolicyBuilder *pb, GNUNET_CONTAINER_DLL_remove (pb->current_policy->pm_head, pb->current_policy->pm_tail, m); + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (m->providers[i].usage_fee); GNUNET_free (m->providers); GNUNET_free (m); } @@ -1317,10 +1340,11 @@ evaluate_map (struct PolicyBuilder *pb, duplicates++; /* penalty for same challenge at two providers */ } } - if (found) - continue; /* cost already included, do not add */ - add_cost (&my_cost, - &pe->usage_fee); + if (! found) + { + add_costs (&my_cost, + pe->usage_fee); + } } } |