GNUnet  0.10.x
gnunet-service-fs_pe.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2011 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet-service-fs.h"
28 #include "gnunet-service-fs_cp.h"
29 #include "gnunet-service-fs_pe.h"
30 #include "gnunet-service-fs_pr.h"
31 
35 #define INSANE_STATISTICS GNUNET_NO
36 
41 struct PendingRequestList;
42 
46 struct PeerPlan;
47 
48 
71 
76 
81 
86 
92 
98 };
99 
100 
112 
117 
122 
126  struct PeerPlan *pp;
127 
134 
139 
143  struct GNUNET_TIME_Absolute earliest_transmission;
144 
149 
153  uint64_t priority;
154 
158  unsigned int transmission_counter;
159 };
160 
161 
165 struct PeerPlan {
170 
175 
183 
188 
193 
198 };
199 
200 
205 
209 static unsigned long long total_delay;
210 
214 static unsigned long long plan_count;
215 
216 
229 static const struct GNUNET_HashCode *
231 {
233 }
234 
235 
242 static void
243 plan(struct PeerPlan *pp,
244  struct GSF_RequestPlan *rp)
245 {
246 #define N ((double)128.0)
247 
250  static double avg_delay;
251 
252  struct GSF_PendingRequestData *prd;
253  struct GNUNET_TIME_Relative delay;
254 
255  GNUNET_assert(rp->pp == pp);
257  gettext_noop("# average retransmission delay (ms)"),
258  total_delay * 1000LL / plan_count, GNUNET_NO);
260 
261  if (rp->transmission_counter < 8)
262  delay =
265  else if (rp->transmission_counter < 32)
266  delay =
268  8 +
269  (1LL << (rp->transmission_counter - 8)));
270  else
271  delay =
273  8 + (1LL << 24));
274  delay.rel_value_us =
276  delay.rel_value_us + 1);
277  /* Add 0.01 to avg_delay to avoid division-by-zero later */
278  avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value_us) / N) + 0.01;
279 
280  /*
281  * For the priority, we need to consider a few basic rules:
282  * 1) if we just started requesting (delay is small), we should
283  * virtually always have a priority of zero.
284  * 2) for requests with average latency, our priority should match
285  * the average priority observed on the network
286  * 3) even the longest-running requests should not be WAY out of
287  * the observed average (thus we bound by a factor of 2)
288  * 4) we add +1 to the observed average priority to avoid everyone
289  * staying put at zero (2 * 0 = 0...).
290  *
291  * Using the specific calculation below, we get:
292  *
293  * delay = 0 => priority = 0;
294  * delay = avg delay => priority = running-average-observed-priority;
295  * delay >> avg_delay => priority = 2 * running-average-observed-priority;
296  *
297  * which satisfies all of the rules above.
298  *
299  * Note: M_PI_4 = PI/4 = arctan(1)
300  */
301  rp->priority =
302  round((GSF_current_priorities +
303  1.0) * atan(delay.rel_value_us / avg_delay)) / M_PI_4;
304  /* Note: usage of 'round' and 'atan' requires -lm */
305 
306  if (rp->transmission_counter != 0)
307  delay.rel_value_us += TTL_DECREMENT * 1000;
309  "Considering (re)transmission number %u in %s\n",
310  (unsigned int)rp->transmission_counter,
312  GNUNET_YES));
315  "Earliest (re)transmission for `%s' in %us\n",
316  GNUNET_h2s(&prd->query),
318  GNUNET_assert(rp->hn == NULL);
321  rp,
322  rp->priority);
323  else
324  rp->hn =
326  rp,
330  get_rp_key(rp),
331  rp));
332 #undef N
333 }
334 
335 
342 struct GSF_PendingRequest *
344 {
345  struct GSF_PendingRequest *ret;
347  const struct GSF_PendingRequestData *rprd;
348  const struct GSF_PendingRequestData *prd;
349 
350  bi = rp->pe_head;
351  if (NULL == bi)
352  return NULL; /* should never happen */
353  ret = bi->pr;
354  rprd = GSF_pending_request_get_data_(ret);
355  for (bi = bi->next_PE; NULL != bi; bi = bi->next_PE)
356  {
360  if (prd->ttl.abs_value_us > rprd->ttl.abs_value_us)
361  {
362  ret = bi->pr;
363  rprd = prd;
364  }
365  }
366  return ret;
367 }
368 
369 
375 static void
377 {
378  struct PeerPlan *pp = cls;
379  struct GSF_RequestPlan *rp;
380  struct GNUNET_TIME_Relative delay;
381 
382  if (NULL != pp->task)
383  {
384  pp->task = NULL;
385  }
386  else
387  {
388  GNUNET_assert(NULL != pp->env);
389  pp->env = NULL;
390  }
391  /* move ready requests to priority queue */
392  while ((NULL != (rp = GNUNET_CONTAINER_heap_peek(pp->delay_heap))) &&
395  {
398  rp,
399  rp->priority);
400  }
402  {
403  /* priority heap (still) empty, check for delay... */
405  if (NULL == rp)
406  {
408  "No active requests for plan %p.\n",
409  pp);
410  return; /* both queues empty */
411  }
414  "Sleeping for %s before retrying requests on plan %p.\n",
416  GNUNET_YES),
417  pp);
419  gettext_noop("# delay heap timeout (ms)"),
420  delay.rel_value_us / 1000LL, GNUNET_NO);
421 
422  pp->task
425  pp);
426  return;
427  }
428 #if INSANE_STATISTICS
430  gettext_noop("# query plans executed"),
431  1,
432  GNUNET_NO);
433 #endif
434  /* process from priority heap */
437  "Executing query plan %p\n",
438  rp);
439  GNUNET_assert(NULL != rp);
440  rp->hn = NULL;
442  rp->transmission_counter++;
443  total_delay++;
445  "Executing plan %p executed %u times, planning retransmission\n",
446  rp,
448  GNUNET_assert(NULL == pp->env);
452  pp);
454  GNUNET_YES,
455  rp->priority,
456  pp->env);
458  gettext_noop("# query messages sent to other peers"),
459  1,
460  GNUNET_NO);
461  plan(pp,
462  rp);
463 }
464 
465 
469 struct MergeContext {
474 
478  int merged;
479 };
480 
481 
492 static int
493 merge_pr(void *cls,
494  const struct GNUNET_HashCode *query,
495  void *element)
496 {
497  struct MergeContext *mpr = cls;
498  struct GSF_RequestPlan *rp = element;
499  struct GSF_PendingRequestData *prd;
501  struct GSF_PendingRequest *latest;
502 
505  if (GNUNET_OK !=
507  rp->pe_head->pr))
508  return GNUNET_YES;
509  /* merge new request with existing request plan */
511  bi->rp = rp;
512  bi->pr = mpr->pr;
513  prd = GSF_pending_request_get_data_(mpr->pr);
515  prd->pr_head,
516  prd->pr_tail,
517  bi);
519  rp->pe_head,
520  rp->pe_tail,
521  bi);
522  mpr->merged = GNUNET_YES;
523 #if INSANE_STATISTICS
525  gettext_noop("# requests merged"),
526  1,
527  GNUNET_NO);
528 #endif
529  latest = get_latest(rp);
530  if (GSF_pending_request_get_data_(latest)->ttl.abs_value_us <
531  prd->ttl.abs_value_us)
532  {
533 #if INSANE_STATISTICS
535  gettext_noop("# requests refreshed"),
536  1,
537  GNUNET_NO);
538 #endif
539  rp->transmission_counter = 0; /* reset */
540  }
541  return GNUNET_NO;
542 }
543 
544 
551 void
553  struct GSF_PendingRequest *pr)
554 {
555  const struct GNUNET_PeerIdentity *id;
556  struct PeerPlan *pp;
557  struct GSF_PendingRequestData *prd;
558  struct GSF_RequestPlan *rp;
560  struct MergeContext mpc;
561 
564  GNUNET_assert(NULL != cp);
566  pp = GNUNET_CONTAINER_multipeermap_get(plans, id);
567  if (NULL == pp)
568  {
569  pp = GNUNET_new(struct PeerPlan);
571  pp->priority_heap =
573  pp->delay_heap =
575  pp->cp = cp;
578  id,
579  pp,
582  pp);
583  }
584  mpc.merged = GNUNET_NO;
585  mpc.pr = pr;
588  &prd->query,
589  &merge_pr,
590  &mpc);
591  if (GNUNET_NO != mpc.merged)
592  return;
593  plan_count++;
595  gettext_noop("# query plan entries"),
596  1,
597  GNUNET_NO);
599  "Planning transmission of query `%s' to peer `%s'\n",
600  GNUNET_h2s(&prd->query),
601  GNUNET_i2s(id));
602  rp = GNUNET_new(struct GSF_RequestPlan);
604  bi->rp = rp;
605  bi->pr = pr;
607  prd->pr_head,
608  prd->pr_tail,
609  bi);
611  rp->pe_head,
612  rp->pe_tail,
613  bi);
614  rp->pp = pp;
617  get_rp_key(rp),
618  rp,
620  plan(pp,
621  rp);
622 }
623 
624 
631 void
633 {
634  const struct GNUNET_PeerIdentity *id;
635  struct PeerPlan *pp;
636  struct GSF_RequestPlan *rp;
637  struct GSF_PendingRequestData *prd;
639 
641  pp = GNUNET_CONTAINER_multipeermap_get(plans, id);
642  if (NULL == pp)
643  return; /* nothing was ever planned for this peer */
646  pp));
647  if (NULL != pp->task)
648  {
650  pp->task = NULL;
651  }
652  while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root(pp->priority_heap)))
653  {
656  get_rp_key(rp),
657  rp));
658  while (NULL != (bi = rp->pe_head))
659  {
661  rp->pe_head,
662  rp->pe_tail,
663  bi);
666  prd->pr_head,
667  prd->pr_tail,
668  bi);
669  GNUNET_free(bi);
670  }
671  plan_count--;
672  GNUNET_free(rp);
673  }
675  while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root(pp->delay_heap)))
676  {
679  get_rp_key(rp),
680  rp));
681  while (NULL != (bi = rp->pe_head))
682  {
685  rp->pe_head,
686  rp->pe_tail,
687  bi);
689  prd->pr_head,
690  prd->pr_tail,
691  bi);
692  GNUNET_free(bi);
693  }
694  plan_count--;
695  GNUNET_free(rp);
696  }
698  gettext_noop("# query plan entries"),
699  plan_count,
700  GNUNET_NO);
703  GNUNET_free(pp);
704 }
705 
706 
716 int
718  struct GSF_ConnectedPeer *sender,
720 {
722 
723  for (bi = pr_head; NULL != bi; bi = bi->next_PR)
724  {
725  if (bi->rp->pp->cp == sender)
726  {
727  if (0 == bi->rp->last_transmission.abs_value_us)
729  else
730  *result = bi->rp->last_transmission;
731  return GNUNET_YES;
732  }
733  }
734  return GNUNET_NO;
735 }
736 
737 
744 void
746 {
747  struct GSF_RequestPlan *rp;
748  struct GSF_PendingRequestData *prd;
750 
752  while (NULL != (bi = prd->pr_head))
753  {
754  rp = bi->rp;
756  prd->pr_head,
757  prd->pr_tail,
758  bi);
760  rp->pe_head,
761  rp->pe_tail,
762  bi);
763  GNUNET_assert(bi->pr == pr);
764  if (NULL == rp->pe_head)
765  {
767  plan_count--;
770  &prd->query,
771  rp));
772  GNUNET_free(rp);
773  }
774  GNUNET_free(bi);
775  }
777  gettext_noop("# query plan entries"),
778  plan_count,
779  GNUNET_NO);
780 }
781 
782 
786 void
788 {
790  GNUNET_YES);
791 }
792 
793 
797 void
799 {
802 }
803 
804 
805 
806 /* end of gnunet-service-fs_pe.h */
API to handle &#39;connected peers&#39;.
Closure for merge_pr().
void GSF_plan_add_(struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
Create a new query plan entry.
uint64_t rel_value_us
The actual value.
static unsigned long long total_delay
Sum of all transmission counters (equals total delay for all plan entries).
void GSF_plan_done()
Shutdown plan subsystem.
int GSF_request_plan_reference_get_last_transmission_(struct GSF_PendingRequestPlanBijection *pr_head, struct GSF_ConnectedPeer *sender, struct GNUNET_TIME_Absolute *result)
Get the last transmission attempt time for the request plan list referenced by pr_head, that was sent to sender.
struct GSF_RequestPlan * next
This is a doubly-linked list.
static GNUNET_CronTime last_transmission
struct GNUNET_CONTAINER_MultiHashMap * plan_map
Map of queries to plan entries.
struct GSF_PendingRequestPlanBijection * next_PE
This is a doubly-linked list.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
double GSF_current_priorities
Typical priorities we&#39;re seeing from other peers right now.
struct GNUNET_TIME_Absolute ttl
Current TTL for the request.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
Transmission plan for a peer.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GSF_peer_transmit_(struct GSF_ConnectedPeer *cp, int is_query, uint32_t priority, struct GNUNET_MQ_Envelope *env)
Transmit a message to the given peer as soon as possible.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_MQ_Envelope * env
Current message under transmission for the plan.
static unsigned long long plan_count
Number of plan entries.
struct GSF_PendingRequestPlanBijection * pr_head
Fields for the plan module to track a DLL with the request.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_NO
Definition: gnunet_common.h:78
shared data structures of gnunet-service-fs.c
struct GSF_PendingRequestPlanBijection * next_PR
This is a doubly-linked list.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GSF_pending_request_is_compatible_(struct GSF_PendingRequest *pra, struct GSF_PendingRequest *prb)
Test if two pending requests are compatible (would generate the same query modulo filters and should ...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
static int ret
Final status code.
Definition: gnunet-arm.c:89
static const struct GNUNET_HashCode * get_rp_key(struct GSF_RequestPlan *rp)
Return the query (key in the plan_map) for the given request plan.
#define N
uint64_t abs_value_us
The actual value.
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GSF_ConnectedPeer * cp
Peer for which this is the plan.
struct GSF_RequestPlan * rp
Associated request plan (tells us one of the peers that we plan to forward the request to)...
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_HashCode query
Primary query hash for this request.
struct GSF_PendingRequestPlanBijection * pe_head
Head of list of associated pending requests.
struct GSF_PendingRequestPlanBijection * pe_tail
Tail of list of associated pending requests.
API to handle pending requests.
struct GNUNET_CONTAINER_Heap * delay_heap
Heap with pending queries (struct GSF_RequestPlan), by transmission time, lowest first.
Public data (in the sense of not encapsulated within &#39;gnunet-service-fs_pr&#39;, not in the sense of netw...
int merged
Set to GNUNET_YES if we succeeded to merge.
API to manage query plan.
static void schedule_peer_transmission(void *cls)
Figure out when and how to transmit to the given peer.
#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element)
Insert an element at the head of a MDLL.
struct GNUNET_TIME_Absolute earliest_transmission
Earliest time we&#39;d be happy to (re)transmit this request.
struct PeerPlan * pp
The transmission plan for a peer that this request is associated with.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:772
unsigned int transmission_counter
How often did we transmit this request to this peer?
int GSF_pending_request_test_active_(struct GSF_PendingRequest *pr)
Check if the given request is still active.
void GSF_plan_init()
Initialize plan subsystem.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
static int result
Global testing status.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:440
static void plan(struct PeerPlan *pp, struct GSF_RequestPlan *rp)
Insert the given request plan into the heap with the appropriate weight.
Handle to a node in a heap.
Internal representation of the hash map.
Heap with the minimum cost at the root.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
A 512-bit hashcode.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
void GSF_plan_notify_request_done_(struct GSF_PendingRequest *pr)
Notify the plan about a request being done; destroy all entries associated with this request...
Node in the heap.
struct GSF_PendingRequest * pr
Associated pending request (identifies request details and one of the origins of the request)...
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GSF_PendingRequestPlanBijection * pr_tail
Fields for the plan module to track a DLL with the request.
struct GNUNET_CONTAINER_HeapNode * hn
Heap node associated with this request and this peer.
struct GNUNET_TIME_Absolute last_transmission
When was the last time we transmitted this request to this peer? 0 for never.
int GNUNET_CONTAINER_multihashmap_contains_value(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Check if the map contains the given value under the given key.
Information we keep per request per peer.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
struct GNUNET_MQ_Envelope * GSF_pending_request_get_message_(struct GSF_PendingRequest *pr)
Generate the message corresponding to the given pending request for transmission to other peers...
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
The identity of the host (wraps the signing key of the peer).
struct GSF_PendingRequestData * GSF_pending_request_get_data_(struct GSF_PendingRequest *pr)
Obtain the public data associated with a pending request.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_(const struct GSF_ConnectedPeer *cp)
Obtain the identity of a connected peer.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
Heap with the maximum cost at the root.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
#define TTL_DECREMENT
By which amount do we decrement the TTL for simple forwarding / indirection of the query; in milli-se...
struct GSF_PendingRequest * pr
Request we are trying to merge.
A connected peer.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GSF_plan_notify_peer_disconnect_(const struct GSF_ConnectedPeer *cp)
Notify the plan about a peer being no longer available; destroy all entries associated with this peer...
struct GSF_RequestPlan * prev
This is a doubly-linked list.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
Time for absolute times used by GNUnet, in microseconds.
struct GSF_PendingRequestPlanBijection * prev_PR
This is a doubly-linked list.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SCHEDULER_Task * task
Current task for executing the plan.
static int merge_pr(void *cls, const struct GNUNET_HashCode *query, void *element)
Iterator that checks if an equivalent request is already present for this peer.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
An active request.
uint64_t priority
Current priority for this request for this target.
static struct GNUNET_CONTAINER_MultiPeerMap * plans
Hash map from peer identities to PeerPlans.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1214
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GSF_PendingRequestPlanBijection * prev_PE
This is a doubly-linked list.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GSF_PendingRequest * get_latest(const struct GSF_RequestPlan *rp)
Get the pending request with the highest TTL from the given plan.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
M:N binding of plans to pending requests.
#define gettext_noop(String)
Definition: gettext.h:69
struct GNUNET_CONTAINER_Heap * priority_heap
Heap with pending queries (struct GSF_RequestPlan), higher weights mean higher priority.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956