summaryrefslogtreecommitdiff
path: root/ot_livesync.h
diff options
context:
space:
mode:
authorerdgeist <>2010-04-22 22:08:42 +0000
committererdgeist <>2010-04-22 22:08:42 +0000
commitd42bf5a0310b8df4babff645ee91c37e9f994bfe (patch)
tree878712aeae9d2c64dc626b2945f11cac50954258 /ot_livesync.h
parentae9ab769415f30ccb444bb0b0190a5fcf22275e7 (diff)
** struct ot_workstruct gets ritcher (and will become even ritcher soon).
This is where we encapsulate all per-request data from peer to hash to peer_id, so that it is available everywhere without passing hundreds of pointers down the stack. Most functions that do work down the stack now accept an ot_workstruct and some flags. So it can end up in the stats/event-handler where it will be the default parameter in the future. ** peer_id is now being copied by default and moved to ot_workstruct So it is available in stats and subsequent functions. ** sync scrape madness is gone SYNC_SCRAPE was intended to sync tracker state that would normally be lost on restarts i.e. downloaded counts per torrent. The way was to push it in the tracker cloud after finding all neighbouring trackers. This is madness. It never was tested and can be done per tracker by fetching stats/mode=statedump from time to time and starting opentracker with the -l option later. ** livesync thread has its own ot_workstruct now So it can behave like ot_udp and ot_http against trackerlogic.c and get rid of the first half of the embarrassing global variables. The sending half will be fixed soon [tm]. ** stats can log completed events The author recognizes the needs of original content distributors to keep track of the amount of times a work has been downloaded. While not feasible and used on openbittorrent and other open and anonymous tracker installations, a tracker user can now choose to send those events to syslog.
Diffstat (limited to 'ot_livesync.h')
-rw-r--r--ot_livesync.h40
1 files changed, 1 insertions, 39 deletions
diff --git a/ot_livesync.h b/ot_livesync.h
index fe9d122..1a3ed45 100644
--- a/ot_livesync.h
+++ b/ot_livesync.h
@@ -35,44 +35,6 @@
35 0x0024 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 ) 35 0x0024 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
36 ]* 36 ]*
37 37
38 ########
39 ######## SCRAPE SYNC PROTOCOL ########
40 ########
41
42 Each tracker instance SHOULD broadcast a beacon every LIVESYNC_BEACON_INTERVAL
43 seconds after running at least LIVESYNC_FIRST_BEACON_DELAY seconds:
44
45 packet type SYNC_SCRAPE_BEACON
46 [ 0x0008 0x08 amount of torrents served
47 ]
48
49 If a tracker instance receives a beacon from another instance that has more than
50 its torrent count plus a threshold, it inquires for a scrape. It must wait for at
51 least 2 * LIVESYNC_BEACON_INTERVAL seconds in order to inspect beacons from all
52 tracker instances and inquire only the one with most torrents.
53
54 If it sees a SYNC_SCRAPE_TELL within that time frame, it's likely, that another
55 scrape sync is going on. It should reset its state to needs no inquiry. It should
56 be reenabled on the next beacon, if still needed.
57
58 packet type SYNC_SCRAPE_INQUIRE
59 [ 0x0008 0x04 id of tracker instance to inquire
60 ]
61
62 The inquired tracker instance answers with as many scrape tell packets it needs
63 to deliver stats about all its torrents
64
65 packet type SYNC_SCRAPE_TELL
66 [ 0x0008 0x14 info_hash
67 0x001c 0x04 base offset (i.e. when was it last announced, in minutes)
68 0x0020 0x08 downloaded count
69 ]*
70
71 Each tracker instance that receives a SYNC_SCRAPE_TELL, looks up each torrent and
72 compares downloaded count with its own counter. It can send out its own scrape
73 tell packets, if it knows more. However to not interrupt a scrape tell, a tracker
74 should wait LIVESYNC_BEACON_INTERVAL after receiving a scrape tell.
75
76*/ 38*/
77 39
78#ifdef WANT_SYNC_LIVE 40#ifdef WANT_SYNC_LIVE
@@ -86,7 +48,7 @@ void livesync_deinit();
86void livesync_bind_mcast( char *ip, uint16_t port ); 48void livesync_bind_mcast( char *ip, uint16_t port );
87 49
88/* Inform live sync about whats going on. */ 50/* Inform live sync about whats going on. */
89void livesync_tell( ot_hash const info_hash, const ot_peer * const peer ); 51void livesync_tell( struct ot_workstruct *ws );
90 52
91/* Tickle the live sync module from time to time, so no events get 53/* Tickle the live sync module from time to time, so no events get
92 stuck when there's not enough traffic to fill udp packets fast 54 stuck when there's not enough traffic to fill udp packets fast