diff options
Diffstat (limited to 'trackerlogic.h')
-rw-r--r-- | trackerlogic.h | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/trackerlogic.h b/trackerlogic.h index 812cfce..178f8db 100644 --- a/trackerlogic.h +++ b/trackerlogic.h | |||
@@ -18,18 +18,12 @@ typedef ot_byte ot_hash[20]; | |||
18 | typedef ot_dword ot_ip; | 18 | typedef ot_dword ot_ip; |
19 | typedef time_t ot_time; | 19 | typedef time_t ot_time; |
20 | 20 | ||
21 | #define MEMMOVE memmove | 21 | /* We maintain a list of 256 pointers to sorted list of ot_torrent structs |
22 | #define BZERO bzero | 22 | Sort key is, of course, its hash */ |
23 | #define FORMAT_FIXED_STRING sprintf | ||
24 | #define FORMAT_FORMAT_STRING sprintf | ||
25 | #define BINARY_FIND binary_search | ||
26 | 23 | ||
27 | // We maintain a list of 256 pointers to sorted list of ot_torrent structs | 24 | /* This list points to 9 pools of peers each grouped in five-minute-intervals |
28 | // Sort key is, of course, its hash | 25 | thus achieving a timeout of 2700s or 45 minutes |
29 | 26 | These pools are sorted by its binary content */ | |
30 | // This list points to 9 pools of peers each grouped in five-minute-intervals | ||
31 | // thus achieving a timeout of 2700s or 45 minutes | ||
32 | // These pools are sorted by its binary content | ||
33 | 27 | ||
34 | #define OT_POOLS_COUNT 9 | 28 | #define OT_POOLS_COUNT 9 |
35 | #define OT_POOLS_TIMEOUT 300 | 29 | #define OT_POOLS_TIMEOUT 300 |
@@ -52,8 +46,8 @@ static const ot_byte PEER_FLAG_SEEDING = 0x80; | |||
52 | static const ot_byte PEER_FLAG_COMPLETED = 0x40; | 46 | static const ot_byte PEER_FLAG_COMPLETED = 0x40; |
53 | static const ot_byte PEER_FLAG_STOPPED = 0x20; | 47 | static const ot_byte PEER_FLAG_STOPPED = 0x20; |
54 | 48 | ||
55 | #define OT_SETIP( peer, ip ) MEMMOVE((peer),(ip),4); | 49 | #define OT_SETIP( peer, ip ) memmove((peer),(ip),4); |
56 | #define OT_SETPORT( peer, port ) MEMMOVE(((ot_byte*)peer)+4,(port),2); | 50 | #define OT_SETPORT( peer, port ) memmove(((ot_byte*)peer)+4,(port),2); |
57 | #define OT_FLAG(peer) (((ot_byte*)(peer))[6]) | 51 | #define OT_FLAG(peer) (((ot_byte*)(peer))[6]) |
58 | 52 | ||
59 | #define OT_PEER_COMPARE_SIZE ((size_t)6) | 53 | #define OT_PEER_COMPARE_SIZE ((size_t)6) |
@@ -61,8 +55,8 @@ static const ot_byte PEER_FLAG_STOPPED = 0x20; | |||
61 | 55 | ||
62 | typedef struct { | 56 | typedef struct { |
63 | ot_time base; | 57 | ot_time base; |
64 | unsigned long seed_count[ OT_POOLS_COUNT ]; | 58 | size_t seed_count[ OT_POOLS_COUNT ]; |
65 | unsigned long downloaded; | 59 | unsigned int downloaded; |
66 | ot_vector peers[ OT_POOLS_COUNT ]; | 60 | ot_vector peers[ OT_POOLS_COUNT ]; |
67 | } ot_peerlist; | 61 | } ot_peerlist; |
68 | 62 | ||
@@ -71,9 +65,9 @@ typedef struct { | |||
71 | ot_peerlist *peer_list; | 65 | ot_peerlist *peer_list; |
72 | } ot_torrent; | 66 | } ot_torrent; |
73 | 67 | ||
74 | // | 68 | /* |
75 | // Exported functions | 69 | Exported functions |
76 | // | 70 | */ |
77 | 71 | ||
78 | int init_logic( char *serverdir ); | 72 | int init_logic( char *serverdir ); |
79 | void deinit_logic( ); | 73 | void deinit_logic( ); |
@@ -86,7 +80,7 @@ extern int g_check_blacklist; | |||
86 | #endif | 80 | #endif |
87 | 81 | ||
88 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ); | 82 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ); |
89 | size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ); | 83 | size_t return_peers_for_torrent( ot_torrent *torrent, unsigned int amount, char *reply ); |
90 | size_t return_scrape_for_torrent( ot_hash *hash, char *reply ); | 84 | size_t return_scrape_for_torrent( ot_hash *hash, char *reply ); |
91 | void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ); | 85 | void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ); |
92 | void cleanup_torrents( void ); | 86 | void cleanup_torrents( void ); |