~ubuntu-branches/ubuntu/precise/transmission/precise

« back to all changes in this revision

Viewing changes to libtransmission/peer-mgr-private.h

  • Committer: Bazaar Package Importer
  • Author(s): Leo Costela
  • Date: 2009-05-17 19:39:51 UTC
  • mto: (1.3.4 upstream) (2.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20090517193951-k8x15sqoxzf7cuyx
ImportĀ upstreamĀ versionĀ 1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file Copyright (C) 2007-2008 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 5179 2008-03-01 14:32:35Z 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
 
 
18
 
#ifdef WIN32
19
 
#include <winsock2.h> /* struct in_addr */
20
 
#else
21
 
#include <netinet/in.h> /* struct in_addr */
22
 
#endif
23
 
 
24
 
#include "publish.h" /* tr_publisher_tag */
25
 
 
26
 
struct tr_bitfield;
27
 
struct tr_peerIo;
28
 
struct tr_peermsgs;
29
 
 
30
 
enum
31
 
{
32
 
    ENCRYPTION_PREFERENCE_UNKNOWN,
33
 
    ENCRYPTION_PREFERENCE_YES,
34
 
    ENCRYPTION_PREFERENCE_NO
35
 
};
36
 
 
37
 
/**
38
 
*** The "SWIFT" system is described by Karthik Tamilmani,
39
 
*** Vinay Pai, and Alexander Mohr of Stony Brook University
40
 
*** in their paper "SWIFT: A System With Incentives For Trading"
41
 
*** http://citeseer.ist.psu.edu/tamilmani04swift.html
42
 
***
43
 
*** More SWIFT constants are defined in peer-mgr.c
44
 
**/
45
 
 
46
 
/**
47
 
 * Use SWIFT?
48
 
 */
49
 
static const int SWIFT_ENABLED = 0;
50
 
 
51
 
/**
52
 
 * For every byte the peer uploads to us,
53
 
 * allow them to download this many bytes from us
54
 
 */
55
 
static const double SWIFT_REPAYMENT_RATIO = 1.33;
56
 
 
57
 
 
58
 
typedef struct tr_peer
59
 
{
60
 
    unsigned int  peerIsChoked : 1;
61
 
    unsigned int  peerIsInterested : 1;
62
 
    unsigned int  clientIsChoked : 1;
63
 
    unsigned int  clientIsInterested : 1;
64
 
    unsigned int  doPurge : 1;
65
 
 
66
 
    /* number of bad pieces they've contributed to */
67
 
    uint8_t strikes;
68
 
 
69
 
    uint8_t encryption_preference;
70
 
    uint16_t port;
71
 
    struct in_addr in_addr;
72
 
    struct tr_peerIo * io;
73
 
 
74
 
    struct tr_bitfield * blame;
75
 
    struct tr_bitfield * have;
76
 
    float progress;
77
 
 
78
 
    /* the client name from the `v' string in LTEP's handshake dictionary */
79
 
    char * client;
80
 
 
81
 
    time_t peerSentPieceDataAt;
82
 
    time_t chokeChangedAt;
83
 
    time_t pieceDataActivityDate;
84
 
 
85
 
    struct tr_peermsgs * msgs;
86
 
    tr_publisher_tag msgsTag;
87
 
 
88
 
    struct tr_ratecontrol * rcToClient;
89
 
    struct tr_ratecontrol * rcToPeer;
90
 
 
91
 
    double rateToClient;
92
 
    double rateToPeer;
93
 
 
94
 
    int64_t credit;
95
 
}
96
 
tr_peer;
97
 
 
98
 
#endif