+/**
+ * Maximum number of outgoing messages we queue per peer.
+ *
+ * Performance measurements for 2 peer setup for 50 MB file
+ * (with MAX_DATASTORE_QUEUE = 1 and RETRY_PROBABILITY_INV = 1):
+ *
+ * 2: 1700 kb/s, 1372 kb/s
+ * 8: 2117 kb/s, 1284 kb/s, 1112 kb/s
+ * 16: 3500 kb/s, 3200 kb/s, 3388 kb/s
+ * 32: 3441 kb/s, 3163 kb/s, 3277 kb/s
+ * 128: 1700 kb/s; 2010 kb/s, 3383 kb/s, 1156 kb/s
+ *
+ * Conclusion: 16 seems to be a pretty good value (stable
+ * and high performance, no excessive memory use).
+ */
+#define MAX_QUEUE_PER_PEER 16
+
+/**
+ * Length of the P2P success tracker. Note that having a very long
+ * list can also hurt performance.
+ */
+#define P2P_SUCCESS_LIST_SIZE 8
+
+/**
+ * Length of the CS-2-P success tracker. Note that
+ * having a very long list can also hurt performance.
+ */
+#define CS2P_SUCCESS_LIST_SIZE 8
+
+
+/**
+ * Performance data kept for a peer.
+ */
+struct GSF_PeerPerformanceData
+{
+
+ /**
+ * Transport performance data.
+ */
+ struct GNUNET_ATS_Information *atsi;
+
+ /**
+ * List of the last clients for which this peer successfully
+ * answered a query.
+ */
+ struct GSF_LocalClient *last_client_replies[CS2P_SUCCESS_LIST_SIZE];
+
+ /**
+ * List of the last PIDs for which
+ * this peer successfully answered a query;
+ * We use 0 to indicate no successful reply.
+ */
+ GNUNET_PEER_Id last_p2p_replies[P2P_SUCCESS_LIST_SIZE];
+
+ /**
+ * Average delay between sending the peer a request and
+ * getting a reply (only calculated over the requests for
+ * which we actually got a reply). Calculated
+ * as a moving average: new_delay = ((n-1)*last_delay+curr_delay) / n
+ */
+ struct GNUNET_TIME_Relative avg_reply_delay;
+
+ /**
+ * If we get content we already have from this peer, for how
+ * long do we block him? Adjusted based on the fraction of
+ * redundant data we receive, between 1s and 1h.
+ */
+ struct GNUNET_TIME_Relative migration_delay;
+
+ /**
+ * Point in time until which this peer does not want us to migrate content
+ * to it.
+ */
+ struct GNUNET_TIME_Absolute migration_blocked_until;
+
+ /**
+ * Transmission times for the last MAX_QUEUE_PER_PEER
+ * requests for this peer. Used as a ring buffer, current
+ * offset is stored in 'last_request_times_off'. If the
+ * oldest entry is more recent than the 'avg_delay', we should
+ * not send any more requests right now.
+ */
+ struct GNUNET_TIME_Absolute last_request_times[MAX_QUEUE_PER_PEER];
+
+ /**
+ * How long does it typically take for us to transmit a message
+ * to this peer? (delay between the request being issued and
+ * the callback being invoked).
+ */
+ struct GNUNET_LOAD_Value *transmission_delay;
+
+ /**
+ * Average priority of successful replies. Calculated
+ * as a moving average: new_avg = ((n-1)*last_avg+curr_prio) / n
+ */
+ double avg_priority;
+
+ /**
+ * The peer's identity.
+ */
+ GNUNET_PEER_Id pid;
+
+ /**
+ * Trust rating for this peer
+ */
+ uint32_t trust;
+
+ /**
+ * Number of pending queries (replies are not counted)
+ */
+ unsigned int pending_queries;
+
+ /**
+ * Number of pending replies (queries are not counted)
+ */
+ unsigned int pending_replies;
+
+};
+
+
+/**
+ * Signature of function called on a connected peer.
+ *
+ * @param cls closure
+ * @param peer identity of the peer
+ * @param cp handle to the connected peer record
+ * @param perf peer performance data
+ */
+typedef void (*GSF_ConnectedPeerIterator) (void *cls,
+ const struct GNUNET_PeerIdentity *
+ peer, struct GSF_ConnectedPeer * cp,
+ const struct GSF_PeerPerformanceData
+ * ppd);
+
+
+/**
+ * Function called to get a message for transmission.
+ *
+ * @param cls closure
+ * @param buf_size number of bytes available in buf
+ * @param buf where to copy the message, NULL on error (peer disconnect)
+ * @return number of bytes copied to 'buf', can be 0 (without indicating an error)
+ */
+typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size,
+ void *buf);
+
+
+/**
+ * Signature of function called on a reservation success or failure.
+ *
+ * @param cls closure
+ * @param cp handle to the connected peer record
+ * @param success GNUNET_YES on success, GNUNET_NO on failure
+ */
+typedef void (*GSF_PeerReserveCallback) (void *cls,
+ struct GSF_ConnectedPeer * cp,
+ int success);
+
+
+/**
+ * Handle to cancel a transmission request.
+ */
+struct GSF_PeerTransmitHandle;
+
+