diff options
Diffstat (limited to 'src/ats/gnunet-service-ats-solver_mlp.c')
-rw-r--r-- | src/ats/gnunet-service-ats-solver_mlp.c | 132 |
1 files changed, 83 insertions, 49 deletions
diff --git a/src/ats/gnunet-service-ats-solver_mlp.c b/src/ats/gnunet-service-ats-solver_mlp.c index f921c1b1f..f36a3808e 100644 --- a/src/ats/gnunet-service-ats-solver_mlp.c +++ b/src/ats/gnunet-service-ats-solver_mlp.c | |||
@@ -177,7 +177,9 @@ mlp_term_hook (void *info, const char *s) | |||
177 | * @return GNUNET_OK | 177 | * @return GNUNET_OK |
178 | */ | 178 | */ |
179 | static int | 179 | static int |
180 | reset_peers (void *cls, const struct GNUNET_HashCode * key, void *value) | 180 | reset_peers (void *cls, |
181 | const struct GNUNET_PeerIdentity *key, | ||
182 | void *value) | ||
181 | { | 183 | { |
182 | struct ATS_Peer *peer = value; | 184 | struct ATS_Peer *peer = value; |
183 | peer->processed = GNUNET_NO; | 185 | peer->processed = GNUNET_NO; |
@@ -237,7 +239,8 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp) | |||
237 | mlp->p.ci = MLP_UNDEFINED; | 239 | mlp->p.ci = MLP_UNDEFINED; |
238 | 240 | ||
239 | 241 | ||
240 | GNUNET_CONTAINER_multihashmap_iterate (mlp->requested_peers, &reset_peers, NULL); | 242 | GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, |
243 | &reset_peers, NULL); | ||
241 | } | 244 | } |
242 | 245 | ||
243 | 246 | ||
@@ -385,28 +388,34 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
385 | 388 | ||
386 | struct CountContext | 389 | struct CountContext |
387 | { | 390 | { |
388 | struct GNUNET_CONTAINER_MultiHashMap * peers; | 391 | const struct GNUNET_CONTAINER_MultiPeerMap *peers; |
389 | int result; | 392 | int result; |
390 | }; | 393 | }; |
391 | 394 | ||
392 | static int | 395 | static int |
393 | mlp_create_problem_count_addresses_it (void *cls, const struct GNUNET_HashCode *key, void *value) | 396 | mlp_create_problem_count_addresses_it (void *cls, |
397 | const struct GNUNET_PeerIdentity *key, | ||
398 | void *value) | ||
394 | { | 399 | { |
395 | struct CountContext *cctx = cls; | 400 | struct CountContext *cctx = cls; |
401 | |||
396 | /* Check if we have to add this peer due to a pending request */ | 402 | /* Check if we have to add this peer due to a pending request */ |
397 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(cctx->peers, key)) | 403 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->peers, key)) |
398 | cctx->result++; | 404 | cctx->result++; |
399 | return GNUNET_OK; | 405 | return GNUNET_OK; |
400 | } | 406 | } |
401 | 407 | ||
402 | static int mlp_create_problem_count_addresses ( | 408 | |
403 | struct GNUNET_CONTAINER_MultiHashMap * peers, | 409 | static int |
404 | const struct GNUNET_CONTAINER_MultiHashMap * addresses) | 410 | mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *peers, |
411 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses) | ||
405 | { | 412 | { |
406 | struct CountContext cctx; | 413 | struct CountContext cctx; |
414 | |||
407 | cctx.peers = peers; | 415 | cctx.peers = peers; |
408 | cctx.result = 0; | 416 | cctx.result = 0; |
409 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &mlp_create_problem_count_addresses_it, &cctx); | 417 | GNUNET_CONTAINER_multipeermap_iterate (addresses, |
418 | &mlp_create_problem_count_addresses_it, &cctx); | ||
410 | return cctx.result; | 419 | return cctx.result; |
411 | } | 420 | } |
412 | 421 | ||
@@ -591,7 +600,9 @@ mlp_create_problem_create_constraint (struct MLP_Problem *p, char *name, | |||
591 | * - Set address dependent entries in problem matrix as well | 600 | * - Set address dependent entries in problem matrix as well |
592 | */ | 601 | */ |
593 | static int | 602 | static int |
594 | mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashCode *key, void *value) | 603 | mlp_create_problem_add_address_information (void *cls, |
604 | const struct GNUNET_PeerIdentity *key, | ||
605 | void *value) | ||
595 | { | 606 | { |
596 | struct GAS_MLP_Handle *mlp = cls; | 607 | struct GAS_MLP_Handle *mlp = cls; |
597 | struct MLP_Problem *p = &mlp->p; | 608 | struct MLP_Problem *p = &mlp->p; |
@@ -604,7 +615,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
604 | int c; | 615 | int c; |
605 | 616 | ||
606 | /* Check if we have to add this peer due to a pending request */ | 617 | /* Check if we have to add this peer due to a pending request */ |
607 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->requested_peers, key)) | 618 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains(mlp->requested_peers, key)) |
608 | return GNUNET_OK; | 619 | return GNUNET_OK; |
609 | 620 | ||
610 | mlpi = address->solver_information; | 621 | mlpi = address->solver_information; |
@@ -616,7 +627,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
616 | } | 627 | } |
617 | 628 | ||
618 | /* Get peer */ | 629 | /* Get peer */ |
619 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, key); | 630 | peer = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, key); |
620 | if (peer->processed == GNUNET_NO) | 631 | if (peer->processed == GNUNET_NO) |
621 | { | 632 | { |
622 | /* Add peer dependent constraints */ | 633 | /* Add peer dependent constraints */ |
@@ -822,14 +833,18 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp) | |||
822 | /* create the glpk problem */ | 833 | /* create the glpk problem */ |
823 | p->prob = glp_create_prob (); | 834 | p->prob = glp_create_prob (); |
824 | GNUNET_assert (NULL != p->prob); | 835 | GNUNET_assert (NULL != p->prob); |
825 | p->num_peers = GNUNET_CONTAINER_multihashmap_size (mlp->requested_peers); | 836 | p->num_peers = GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers); |
826 | p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses); | 837 | p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses); |
827 | 838 | ||
828 | /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */ | 839 | /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */ |
829 | p->num_elements = (10 * p->num_addresses + mlp->pv.m_q * p->num_addresses + | 840 | p->num_elements = (10 * p->num_addresses + mlp->pv.m_q * p->num_addresses + |
830 | mlp->pv.m_q + p->num_peers + 2 + 1); | 841 | mlp->pv.m_q + p->num_peers + 2 + 1); |
831 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n", | 842 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
832 | p->num_peers, p->num_addresses, mlp->pv.m_q, p->num_elements); | 843 | "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n", |
844 | p->num_peers, | ||
845 | p->num_addresses, | ||
846 | mlp->pv.m_q, | ||
847 | p->num_elements); | ||
833 | 848 | ||
834 | /* Set a problem name */ | 849 | /* Set a problem name */ |
835 | glp_set_prob_name (p->prob, "GNUnet ATS bandwidth distribution"); | 850 | glp_set_prob_name (p->prob, "GNUnet ATS bandwidth distribution"); |
@@ -859,7 +874,9 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp) | |||
859 | mlp_create_problem_add_invariant_rows (mlp, p); | 874 | mlp_create_problem_add_invariant_rows (mlp, p); |
860 | 875 | ||
861 | /* Adding address dependent columns constraint rows */ | 876 | /* Adding address dependent columns constraint rows */ |
862 | GNUNET_CONTAINER_multihashmap_iterate (mlp->addresses, &mlp_create_problem_add_address_information, mlp); | 877 | GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses, |
878 | &mlp_create_problem_add_address_information, | ||
879 | mlp); | ||
863 | 880 | ||
864 | /* Load the matrix */ | 881 | /* Load the matrix */ |
865 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Loading matrix\n"); | 882 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Loading matrix\n"); |
@@ -941,10 +958,12 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) | |||
941 | * @param cls the MLP handle | 958 | * @param cls the MLP handle |
942 | * @param key the peer identity | 959 | * @param key the peer identity |
943 | * @param value the address | 960 | * @param value the address |
944 | * @return GNUNET_OK to continue | 961 | * @return #GNUNET_OK to continue |
945 | */ | 962 | */ |
946 | int | 963 | int |
947 | mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value) | 964 | mlp_propagate_results (void *cls, |
965 | const struct GNUNET_PeerIdentity *key, | ||
966 | void *value) | ||
948 | { | 967 | { |
949 | struct GAS_MLP_Handle *mlp = cls; | 968 | struct GAS_MLP_Handle *mlp = cls; |
950 | struct ATS_Address *address; | 969 | struct ATS_Address *address; |
@@ -954,7 +973,8 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value | |||
954 | double mlp_use = MLP_NaN; | 973 | double mlp_use = MLP_NaN; |
955 | 974 | ||
956 | /* Check if we have to add this peer due to a pending request */ | 975 | /* Check if we have to add this peer due to a pending request */ |
957 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->requested_peers, key)) | 976 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mlp->requested_peers, |
977 | key)) | ||
958 | { | 978 | { |
959 | return GNUNET_OK; | 979 | return GNUNET_OK; |
960 | } | 980 | } |
@@ -1082,9 +1102,9 @@ GAS_mlp_solve_problem (void *solver) | |||
1082 | return GNUNET_NO; | 1102 | return GNUNET_NO; |
1083 | } | 1103 | } |
1084 | 1104 | ||
1085 | if (0 == GNUNET_CONTAINER_multihashmap_size(mlp->requested_peers)) | 1105 | if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers)) |
1086 | return GNUNET_OK; /* No pending requests */ | 1106 | return GNUNET_OK; /* No pending requests */ |
1087 | if (0 == GNUNET_CONTAINER_multihashmap_size(mlp->addresses)) | 1107 | if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses)) |
1088 | return GNUNET_OK; /* No addresses available */ | 1108 | return GNUNET_OK; /* No addresses available */ |
1089 | 1109 | ||
1090 | if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) | 1110 | if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) |
@@ -1149,7 +1169,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1149 | /* Propagate result*/ | 1169 | /* Propagate result*/ |
1150 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) | 1170 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) |
1151 | { | 1171 | { |
1152 | GNUNET_CONTAINER_multihashmap_iterate (mlp->addresses, &mlp_propagate_results, mlp); | 1172 | GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses, &mlp_propagate_results, mlp); |
1153 | } | 1173 | } |
1154 | 1174 | ||
1155 | struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); | 1175 | struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); |
@@ -1201,13 +1221,16 @@ GAS_mlp_address_add (void *solver, | |||
1201 | 1221 | ||
1202 | if (NULL == address->solver_information) | 1222 | if (NULL == address->solver_information) |
1203 | { | 1223 | { |
1204 | address->solver_information = GNUNET_malloc (sizeof (struct MLP_information)); | 1224 | address->solver_information = GNUNET_new (struct MLP_information); |
1205 | } | 1225 | } |
1206 | else | 1226 | else |
1207 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Adding address for peer `%s' multiple times\n"), GNUNET_i2s(&address->peer)); | 1227 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1228 | _("Adding address for peer `%s' multiple times\n"), | ||
1229 | GNUNET_i2s(&address->peer)); | ||
1208 | 1230 | ||
1209 | /* Is this peer included in the problem? */ | 1231 | /* Is this peer included in the problem? */ |
1210 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &address->peer.hashPubKey))) | 1232 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1233 | &address->peer))) | ||
1211 | { | 1234 | { |
1212 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' without address request \n", GNUNET_i2s(&address->peer)); | 1235 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' without address request \n", GNUNET_i2s(&address->peer)); |
1213 | return; | 1236 | return; |
@@ -1257,8 +1280,8 @@ GAS_mlp_address_property_changed (void *solver, | |||
1257 | return; | 1280 | return; |
1258 | } | 1281 | } |
1259 | 1282 | ||
1260 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, | 1283 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1261 | &address->peer.hashPubKey))) | 1284 | &address->peer))) |
1262 | { | 1285 | { |
1263 | /* Peer is not requested, so no need to update problem */ | 1286 | /* Peer is not requested, so no need to update problem */ |
1264 | return; | 1287 | return; |
@@ -1368,8 +1391,8 @@ GAS_mlp_address_change_network (void *solver, | |||
1368 | if (mlpi->c_b == MLP_UNDEFINED) | 1391 | if (mlpi->c_b == MLP_UNDEFINED) |
1369 | return; /* This address is not yet in the matrix*/ | 1392 | return; /* This address is not yet in the matrix*/ |
1370 | 1393 | ||
1371 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, | 1394 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1372 | &address->peer.hashPubKey))) | 1395 | &address->peer))) |
1373 | { | 1396 | { |
1374 | /* Peer is not requested, so no need to update problem */ | 1397 | /* Peer is not requested, so no need to update problem */ |
1375 | GNUNET_break (0); | 1398 | GNUNET_break (0); |
@@ -1467,7 +1490,8 @@ GAS_mlp_address_delete (void *solver, | |||
1467 | address->assigned_bw_out = BANDWIDTH_ZERO; | 1490 | address->assigned_bw_out = BANDWIDTH_ZERO; |
1468 | 1491 | ||
1469 | /* Is this peer included in the problem? */ | 1492 | /* Is this peer included in the problem? */ |
1470 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &address->peer.hashPubKey))) | 1493 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1494 | &address->peer))) | ||
1471 | { | 1495 | { |
1472 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s for peer `%s' without address request \n", | 1496 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s for peer `%s' without address request \n", |
1473 | (session_only == GNUNET_YES) ? "session" : "address", | 1497 | (session_only == GNUNET_YES) ? "session" : "address", |
@@ -1505,12 +1529,15 @@ GAS_mlp_address_delete (void *solver, | |||
1505 | * @return GNUNET_OK | 1529 | * @return GNUNET_OK |
1506 | */ | 1530 | */ |
1507 | static int | 1531 | static int |
1508 | mlp_get_preferred_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) | 1532 | mlp_get_preferred_address_it (void *cls, |
1533 | const struct GNUNET_PeerIdentity *key, | ||
1534 | void *value) | ||
1509 | { | 1535 | { |
1510 | static int counter = 0; | 1536 | static int counter = 0; |
1511 | struct ATS_Address **aa = (struct ATS_Address **) cls; | 1537 | struct ATS_Address **aa = cls; |
1512 | struct ATS_Address *addr = value; | 1538 | struct ATS_Address *addr = value; |
1513 | struct MLP_information *mlpi = addr->solver_information; | 1539 | struct MLP_information *mlpi = addr->solver_information; |
1540 | |||
1514 | if (mlpi == NULL) | 1541 | if (mlpi == NULL) |
1515 | return GNUNET_YES; | 1542 | return GNUNET_YES; |
1516 | 1543 | ||
@@ -1536,7 +1563,8 @@ mlp_get_preferred_address_it (void *cls, const struct GNUNET_HashCode * key, voi | |||
1536 | } | 1563 | } |
1537 | 1564 | ||
1538 | 1565 | ||
1539 | static double get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer) | 1566 | static double |
1567 | get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer) | ||
1540 | { | 1568 | { |
1541 | double res; | 1569 | double res; |
1542 | const double *preferences = NULL; | 1570 | const double *preferences = NULL; |
@@ -1579,22 +1607,25 @@ GAS_mlp_get_preferred_address (void *solver, | |||
1579 | GNUNET_i2s (peer)); | 1607 | GNUNET_i2s (peer)); |
1580 | 1608 | ||
1581 | /* Is this peer included in the problem? */ | 1609 | /* Is this peer included in the problem? */ |
1582 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &peer->hashPubKey))) | 1610 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1583 | { | 1611 | peer))) |
1612 | { | ||
1584 | LOG (GNUNET_ERROR_TYPE_INFO, "Adding peer `%s' to list of requested_peers with requests\n", | 1613 | LOG (GNUNET_ERROR_TYPE_INFO, "Adding peer `%s' to list of requested_peers with requests\n", |
1585 | GNUNET_i2s (peer)); | 1614 | GNUNET_i2s (peer)); |
1586 | 1615 | ||
1587 | p = GNUNET_malloc (sizeof (struct ATS_Peer)); | 1616 | p = GNUNET_malloc (sizeof (struct ATS_Peer)); |
1588 | p->id = (*peer); | 1617 | p->id = (*peer); |
1589 | p->f = get_peer_pref_value (mlp, peer); | 1618 | p->f = get_peer_pref_value (mlp, peer); |
1590 | GNUNET_CONTAINER_multihashmap_put (mlp->requested_peers, &peer->hashPubKey, p, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1619 | GNUNET_CONTAINER_multipeermap_put (mlp->requested_peers, |
1620 | peer, p, | ||
1621 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
1591 | 1622 | ||
1592 | /* Added new peer, we have to rebuild problem before solving */ | 1623 | /* Added new peer, we have to rebuild problem before solving */ |
1593 | mlp->mlp_prob_changed = GNUNET_YES; | 1624 | mlp->mlp_prob_changed = GNUNET_YES; |
1594 | 1625 | ||
1595 | if ((GNUNET_YES == mlp->mlp_auto_solve)&& | 1626 | if ((GNUNET_YES == mlp->mlp_auto_solve)&& |
1596 | (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(mlp->addresses, | 1627 | (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains(mlp->addresses, |
1597 | &peer->hashPubKey))) | 1628 | peer))) |
1598 | { | 1629 | { |
1599 | mlp->exclude_peer = peer; | 1630 | mlp->exclude_peer = peer; |
1600 | GAS_mlp_solve_problem (mlp); | 1631 | GAS_mlp_solve_problem (mlp); |
@@ -1603,7 +1634,7 @@ GAS_mlp_get_preferred_address (void *solver, | |||
1603 | } | 1634 | } |
1604 | /* Get prefered address */ | 1635 | /* Get prefered address */ |
1605 | res = NULL; | 1636 | res = NULL; |
1606 | GNUNET_CONTAINER_multihashmap_get_multiple (mlp->addresses, &peer->hashPubKey, | 1637 | GNUNET_CONTAINER_multipeermap_get_multiple (mlp->addresses, peer, |
1607 | mlp_get_preferred_address_it, &res); | 1638 | mlp_get_preferred_address_it, &res); |
1608 | return res; | 1639 | return res; |
1609 | } | 1640 | } |
@@ -1664,9 +1695,9 @@ GAS_mlp_stop_get_preferred_address (void *solver, | |||
1664 | 1695 | ||
1665 | GNUNET_assert (NULL != solver); | 1696 | GNUNET_assert (NULL != solver); |
1666 | GNUNET_assert (NULL != peer); | 1697 | GNUNET_assert (NULL != peer); |
1667 | if (NULL != (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &peer->hashPubKey))) | 1698 | if (NULL != (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) |
1668 | { | 1699 | { |
1669 | GNUNET_CONTAINER_multihashmap_remove (mlp->requested_peers, &peer->hashPubKey, p); | 1700 | GNUNET_CONTAINER_multipeermap_remove (mlp->requested_peers, peer, p); |
1670 | GNUNET_free (p); | 1701 | GNUNET_free (p); |
1671 | 1702 | ||
1672 | mlp->mlp_prob_changed = GNUNET_YES; | 1703 | mlp->mlp_prob_changed = GNUNET_YES; |
@@ -1704,7 +1735,7 @@ GAS_mlp_address_change_preference (void *solver, | |||
1704 | /* Update quality constraint c7 */ | 1735 | /* Update quality constraint c7 */ |
1705 | 1736 | ||
1706 | /* Update relativity constraint c9 */ | 1737 | /* Update relativity constraint c9 */ |
1707 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &peer->hashPubKey))) | 1738 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) |
1708 | { | 1739 | { |
1709 | LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); | 1740 | LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); |
1710 | return; | 1741 | return; |
@@ -1749,12 +1780,13 @@ GAS_mlp_address_preference_feedback (void *solver, | |||
1749 | 1780 | ||
1750 | 1781 | ||
1751 | static int | 1782 | static int |
1752 | mlp_free_peers (void *cls, const struct GNUNET_HashCode *key, void *value) | 1783 | mlp_free_peers (void *cls, |
1784 | const struct GNUNET_PeerIdentity *key, void *value) | ||
1753 | { | 1785 | { |
1754 | struct GNUNET_CONTAINER_MultiHashMap *map = cls; | 1786 | struct GNUNET_CONTAINER_MultiPeerMap *map = cls; |
1755 | struct ATS_Peer *p = value; | 1787 | struct ATS_Peer *p = value; |
1756 | 1788 | ||
1757 | GNUNET_CONTAINER_multihashmap_remove (map, key, value); | 1789 | GNUNET_CONTAINER_multipeermap_remove (map, key, value); |
1758 | GNUNET_free (p); | 1790 | GNUNET_free (p); |
1759 | 1791 | ||
1760 | return GNUNET_OK; | 1792 | return GNUNET_OK; |
@@ -1775,8 +1807,10 @@ GAS_mlp_done (void *solver) | |||
1775 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n"); | 1807 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n"); |
1776 | mlp_delete_problem (mlp); | 1808 | mlp_delete_problem (mlp); |
1777 | 1809 | ||
1778 | GNUNET_CONTAINER_multihashmap_iterate (mlp->requested_peers, &mlp_free_peers, mlp->requested_peers); | 1810 | GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, |
1779 | GNUNET_CONTAINER_multihashmap_destroy (mlp->requested_peers); | 1811 | &mlp_free_peers, |
1812 | mlp->requested_peers); | ||
1813 | GNUNET_CONTAINER_multipeermap_destroy (mlp->requested_peers); | ||
1780 | mlp->requested_peers = NULL; | 1814 | mlp->requested_peers = NULL; |
1781 | 1815 | ||
1782 | /* Clean up GLPK environment */ | 1816 | /* Clean up GLPK environment */ |
@@ -1808,7 +1842,7 @@ GAS_mlp_done (void *solver) | |||
1808 | void * | 1842 | void * |
1809 | GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1843 | GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1810 | const struct GNUNET_STATISTICS_Handle *stats, | 1844 | const struct GNUNET_STATISTICS_Handle *stats, |
1811 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, | 1845 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
1812 | int *network, | 1846 | int *network, |
1813 | unsigned long long *out_dest, | 1847 | unsigned long long *out_dest, |
1814 | unsigned long long *in_dest, | 1848 | unsigned long long *in_dest, |
@@ -2052,7 +2086,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2052 | mlp->mlp_prob_changed = GNUNET_NO; | 2086 | mlp->mlp_prob_changed = GNUNET_NO; |
2053 | mlp->mlp_prob_updated = GNUNET_NO; | 2087 | mlp->mlp_prob_updated = GNUNET_NO; |
2054 | mlp->mlp_auto_solve = GNUNET_YES; | 2088 | mlp->mlp_auto_solve = GNUNET_YES; |
2055 | mlp->requested_peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 2089 | mlp->requested_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
2056 | mlp->bulk_request = 0; | 2090 | mlp->bulk_request = 0; |
2057 | mlp->bulk_lock = 0; | 2091 | mlp->bulk_lock = 0; |
2058 | 2092 | ||