summaryrefslogtreecommitdiff
path: root/src/reducer
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-26 20:54:51 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-26 20:54:51 +0200
commitdcbd1a01050142f2a0a6357a51e80184850ca52e (patch)
tree676508dd698ccabf3ad4a9ba760e36eeaf0acdc1 /src/reducer
parentfdc1f5e2bd9c67a2f45bd885e274b0ad2330a070 (diff)
downloadanastasis-dcbd1a01050142f2a0a6357a51e80184850ca52e.tar.gz
anastasis-dcbd1a01050142f2a0a6357a51e80184850ca52e.tar.bz2
anastasis-dcbd1a01050142f2a0a6357a51e80184850ca52e.zip
handle currency mismatch
Diffstat (limited to 'src/reducer')
-rw-r--r--src/reducer/anastasis_api_backup_redux.c42
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);
+ }
}
}