summaryrefslogtreecommitdiff
path: root/trackerlogic.h
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.h')
-rw-r--r--trackerlogic.h38
1 files changed, 24 insertions, 14 deletions
diff --git a/trackerlogic.h b/trackerlogic.h
index 96b59f3..fd8f48a 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -20,6 +20,16 @@ typedef ot_byte ot_hash[20];
20typedef ot_dword ot_ip; 20typedef ot_dword ot_ip;
21typedef time_t ot_time; 21typedef time_t ot_time;
22 22
23#define OT_VECTOR_MIN_MEMBERS 4
24#define OT_VECTOR_GROW_RATIO 8
25#define OT_VECTOR_SHRINK_THRESH 6
26#define OT_VECTOR_SHRINK_RATIO 4
27typedef struct {
28 void *data;
29 size_t size;
30 size_t space;
31} ot_vector;
32
23/* Some tracker behaviour tunable */ 33/* Some tracker behaviour tunable */
24#define OT_CLIENT_TIMEOUT 30 34#define OT_CLIENT_TIMEOUT 30
25#define OT_CLIENT_TIMEOUT_CHECKINTERVAL 10 35#define OT_CLIENT_TIMEOUT_CHECKINTERVAL 10
@@ -32,8 +42,13 @@ typedef time_t ot_time;
32 42
33#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) ) 43#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) )
34 44
35/* We maintain a list of 256 pointers to sorted list of ot_torrent structs 45/* We maintain a list of 4096 pointers to sorted list of ot_torrent structs
36 Sort key is, of course, its hash */ 46 Sort key is, of course, its hash */
47#define OT_BUCKET_COUNT 1024
48static inline ot_vector *hash_to_bucket( ot_vector *vectors, ot_hash *hash ) {
49 unsigned char *local_hash = hash[0];
50 return vectors + ( ( local_hash[0] << 2 ) | ( local_hash[1] >> 6 ) );
51}
37 52
38/* This list points to 9 pools of peers each grouped in five-minute-intervals 53/* This list points to 9 pools of peers each grouped in five-minute-intervals
39 thus achieving a timeout of 2700s or 45 minutes 54 thus achieving a timeout of 2700s or 45 minutes
@@ -45,16 +60,6 @@ typedef time_t ot_time;
45extern time_t g_now; 60extern time_t g_now;
46#define NOW (g_now/OT_POOLS_TIMEOUT) 61#define NOW (g_now/OT_POOLS_TIMEOUT)
47 62
48#define OT_VECTOR_MIN_MEMBERS 4
49#define OT_VECTOR_GROW_RATIO 8
50#define OT_VECTOR_SHRINK_THRESH 6
51#define OT_VECTOR_SHRINK_RATIO 4
52typedef struct {
53 void *data;
54 size_t size;
55 size_t space;
56} ot_vector;
57
58typedef struct { 63typedef struct {
59 ot_byte data[8]; 64 ot_byte data[8];
60} ot_peer; 65} ot_peer;
@@ -71,8 +76,10 @@ static const ot_byte PEER_FLAG_STOPPED = 0x20;
71 76
72typedef struct { 77typedef struct {
73 ot_time base; 78 ot_time base;
74 size_t seed_count[ OT_POOLS_COUNT ]; 79 size_t seed_count;
75 size_t downloaded; 80 size_t peer_count;
81 size_t down_count;
82 size_t seed_counts[ OT_POOLS_COUNT ];
76 ot_vector peers[ OT_POOLS_COUNT ]; 83 ot_vector peers[ OT_POOLS_COUNT ];
77} ot_peerlist; 84} ot_peerlist;
78 85
@@ -100,9 +107,12 @@ size_t return_stats_for_tracker( char *reply, int mode );
100size_t return_stats_for_slash24s( char *reply, size_t amount, ot_dword thresh ); 107size_t return_stats_for_slash24s( char *reply, size_t amount, ot_dword thresh );
101size_t return_stats_for_slash24s_old( char *reply, size_t amount, ot_dword thresh ); 108size_t return_stats_for_slash24s_old( char *reply, size_t amount, ot_dword thresh );
102size_t return_memstat_for_tracker( char **reply ); 109size_t return_memstat_for_tracker( char **reply );
110void clean_all_torrents( void );
111
112#ifdef WANT_TRACKER_SYNC
103size_t return_changeset_for_tracker( char **reply ); 113size_t return_changeset_for_tracker( char **reply );
104int add_changeset_to_tracker( ot_byte *data, size_t len ); 114int add_changeset_to_tracker( ot_byte *data, size_t len );
105void clean_all_torrents( void ); 115#endif
106 116
107#if defined ( WANT_BLACKLISTING ) || defined ( WANT_CLOSED_TRACKER ) 117#if defined ( WANT_BLACKLISTING ) || defined ( WANT_CLOSED_TRACKER )
108int accesslist_addentry( ot_hash *hash ); 118int accesslist_addentry( ot_hash *hash );