2007-09-20 16:32:01 +00:00
|
|
|
/*
|
2008-01-01 17:20:20 +00:00
|
|
|
* This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com>
|
2007-09-20 16:32:01 +00:00
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TR_PEER_MGR_PRIVATE_H
|
|
|
|
#define TR_PEER_MGR_PRIVATE_H
|
|
|
|
|
|
|
|
#include <inttypes.h> /* uint16_t */
|
2008-01-10 18:52:46 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h> /* struct in_addr */
|
|
|
|
#else
|
2007-10-25 13:59:46 +00:00
|
|
|
#include <netinet/in.h> /* struct in_addr */
|
2008-01-10 18:52:46 +00:00
|
|
|
#endif
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
#include "publish.h" /* tr_publisher_tag */
|
|
|
|
|
|
|
|
struct tr_bitfield;
|
|
|
|
struct tr_peerIo;
|
|
|
|
struct tr_peermsgs;
|
|
|
|
|
2007-09-29 00:46:41 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ENCRYPTION_PREFERENCE_UNKNOWN,
|
|
|
|
ENCRYPTION_PREFERENCE_YES,
|
|
|
|
ENCRYPTION_PREFERENCE_NO
|
|
|
|
};
|
|
|
|
|
2007-11-18 01:00:49 +00:00
|
|
|
/**
|
|
|
|
*** The "SWIFT" system is described by Karthik Tamilmani,
|
|
|
|
*** Vinay Pai, and Alexander Mohr of Stony Brook University
|
|
|
|
*** in their paper "SWIFT: A System With Incentives For Trading"
|
|
|
|
*** http://citeseer.ist.psu.edu/tamilmani04swift.html
|
|
|
|
***
|
|
|
|
*** More SWIFT constants are defined in peer-mgr.c
|
|
|
|
**/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use SWIFT?
|
|
|
|
*/
|
2008-02-08 19:34:12 +00:00
|
|
|
static const int SWIFT_ENABLED = 0;
|
2007-11-18 01:00:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For every byte the peer uploads to us,
|
|
|
|
* allow them to download this many bytes from us
|
|
|
|
*/
|
|
|
|
static const double SWIFT_REPAYMENT_RATIO = 1.33;
|
|
|
|
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_peer
|
|
|
|
{
|
|
|
|
unsigned int peerIsChoked : 1;
|
|
|
|
unsigned int peerIsInterested : 1;
|
|
|
|
unsigned int clientIsChoked : 1;
|
|
|
|
unsigned int clientIsInterested : 1;
|
2007-09-26 04:44:54 +00:00
|
|
|
unsigned int doPurge : 1;
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2007-10-08 01:31:27 +00:00
|
|
|
/* number of bad pieces they've contributed to */
|
|
|
|
uint8_t strikes;
|
|
|
|
|
2007-09-29 00:46:41 +00:00
|
|
|
uint8_t encryption_preference;
|
2007-09-20 16:32:01 +00:00
|
|
|
uint16_t port;
|
2007-09-26 01:55:04 +00:00
|
|
|
struct in_addr in_addr;
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_peerIo * io;
|
|
|
|
|
|
|
|
struct tr_bitfield * blame;
|
|
|
|
struct tr_bitfield * have;
|
|
|
|
float progress;
|
|
|
|
|
|
|
|
/* the client name from the `v' string in LTEP's handshake dictionary */
|
|
|
|
char * client;
|
|
|
|
|
2007-09-23 02:19:59 +00:00
|
|
|
time_t peerSentPieceDataAt;
|
2007-09-22 00:22:10 +00:00
|
|
|
time_t chokeChangedAt;
|
2007-10-02 19:25:18 +00:00
|
|
|
time_t pieceDataActivityDate;
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
struct tr_peermsgs * msgs;
|
|
|
|
tr_publisher_tag msgsTag;
|
2007-10-01 16:31:17 +00:00
|
|
|
|
2007-10-06 18:20:52 +00:00
|
|
|
struct tr_ratecontrol * rcToClient;
|
|
|
|
struct tr_ratecontrol * rcToPeer;
|
|
|
|
|
|
|
|
double rateToClient;
|
|
|
|
double rateToPeer;
|
2007-11-18 01:00:49 +00:00
|
|
|
|
|
|
|
int64_t credit;
|
2007-09-20 16:32:01 +00:00
|
|
|
}
|
|
|
|
tr_peer;
|
|
|
|
|
|
|
|
#endif
|