diff options
Diffstat (limited to 'ot_livesync.h')
| -rw-r--r-- | ot_livesync.h | 40 |
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(); | |||
| 86 | void livesync_bind_mcast( char *ip, uint16_t port ); | 48 | void 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. */ |
| 89 | void livesync_tell( ot_hash const info_hash, const ot_peer * const peer ); | 51 | void 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 |
