1 | /* |
---|
2 | * This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.com> |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: peer-mgr-private.h 3949 2007-11-24 04:53:44Z charles $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef TR_PEER_MGR_PRIVATE_H |
---|
14 | #define TR_PEER_MGR_PRIVATE_H |
---|
15 | |
---|
16 | #include <inttypes.h> /* uint16_t */ |
---|
17 | #include <netinet/in.h> /* struct in_addr */ |
---|
18 | #include "publish.h" /* tr_publisher_tag */ |
---|
19 | |
---|
20 | struct tr_bitfield; |
---|
21 | struct tr_peerIo; |
---|
22 | struct tr_peermsgs; |
---|
23 | |
---|
24 | enum |
---|
25 | { |
---|
26 | ENCRYPTION_PREFERENCE_UNKNOWN, |
---|
27 | ENCRYPTION_PREFERENCE_YES, |
---|
28 | ENCRYPTION_PREFERENCE_NO |
---|
29 | }; |
---|
30 | |
---|
31 | /** |
---|
32 | *** The "SWIFT" system is described by Karthik Tamilmani, |
---|
33 | *** Vinay Pai, and Alexander Mohr of Stony Brook University |
---|
34 | *** in their paper "SWIFT: A System With Incentives For Trading" |
---|
35 | *** http://citeseer.ist.psu.edu/tamilmani04swift.html |
---|
36 | *** |
---|
37 | *** More SWIFT constants are defined in peer-mgr.c |
---|
38 | **/ |
---|
39 | |
---|
40 | /** |
---|
41 | * Use SWIFT? |
---|
42 | */ |
---|
43 | static const int SWIFT_ENABLED = 1; |
---|
44 | |
---|
45 | /** |
---|
46 | * For every byte the peer uploads to us, |
---|
47 | * allow them to download this many bytes from us |
---|
48 | */ |
---|
49 | static const double SWIFT_REPAYMENT_RATIO = 1.33; |
---|
50 | |
---|
51 | |
---|
52 | typedef struct tr_peer |
---|
53 | { |
---|
54 | unsigned int peerIsChoked : 1; |
---|
55 | unsigned int peerIsInterested : 1; |
---|
56 | unsigned int clientIsChoked : 1; |
---|
57 | unsigned int clientIsInterested : 1; |
---|
58 | unsigned int doPurge : 1; |
---|
59 | |
---|
60 | tr_peer_status status; |
---|
61 | |
---|
62 | /* number of bad pieces they've contributed to */ |
---|
63 | uint8_t strikes; |
---|
64 | |
---|
65 | uint8_t encryption_preference; |
---|
66 | uint16_t port; |
---|
67 | struct in_addr in_addr; |
---|
68 | struct tr_peerIo * io; |
---|
69 | |
---|
70 | struct tr_bitfield * banned; |
---|
71 | struct tr_bitfield * blame; |
---|
72 | struct tr_bitfield * have; |
---|
73 | float progress; |
---|
74 | |
---|
75 | /* the client name from the `v' string in LTEP's handshake dictionary */ |
---|
76 | char * client; |
---|
77 | |
---|
78 | time_t peerSentPieceDataAt; |
---|
79 | time_t chokeChangedAt; |
---|
80 | time_t pieceDataActivityDate; |
---|
81 | |
---|
82 | struct tr_peermsgs * msgs; |
---|
83 | tr_publisher_tag msgsTag; |
---|
84 | |
---|
85 | struct tr_ratecontrol * rcToClient; |
---|
86 | struct tr_ratecontrol * rcToPeer; |
---|
87 | |
---|
88 | double rateToClient; |
---|
89 | double rateToPeer; |
---|
90 | |
---|
91 | int64_t credit; |
---|
92 | } |
---|
93 | tr_peer; |
---|
94 | |
---|
95 | #endif |
---|