Changeset 13947


Ignore:
Timestamp:
Feb 3, 2013, 10:40:00 PM (8 years ago)
Author:
jordan
Message:

(libT) move the tr_peer declaration from peer-mgr.h to peer-common.h

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-common.h

    r13936 r13947  
    2828
    2929#include "transmission.h"
    30 
    31 struct tr_bitfield;
     30#include "bitfield.h"
     31#include "history.h"
     32#include "quark.h"
    3233
    3334enum
     
    8182extern const tr_peer_event TR_PEER_EVENT_INIT;
    8283
    83 struct tr_peer;
     84/**
     85 * State information about a connected peer.
     86 *
     87 * @see struct peer_atom
     88 * @see tr_peermsgs
     89 */
     90typedef struct tr_peer
     91{
     92  /* whether or not we should free this peer soon.
     93     NOTE: private to peer-mgr.c */
     94  bool doPurge;
     95
     96  /* Whether or not we've choked this peer.
     97     Only applies to BitTorrent peers */
     98  bool peerIsChoked;
     99
     100  /* whether or not the peer has indicated it will download from us.
     101     Only applies to BitTorrent peers */
     102  bool peerIsInterested;
     103
     104  /* whether or the peer is choking us.
     105     Only applies to BitTorrent peers */
     106  bool clientIsChoked;
     107
     108  /* whether or not we've indicated to the peer that we would download from them if unchoked.
     109     Only applies to BitTorrent peers */
     110  bool clientIsInterested;
     111
     112  /* number of bad pieces they've contributed to */
     113  uint8_t strikes;
     114
     115  uint8_t encryption_preference;
     116
     117  /* how many requests the peer has made that we haven't responded to yet */
     118  int pendingReqsToClient;
     119
     120  /* how many requests we've made and are currently awaiting a response for */
     121  int pendingReqsToPeer;
     122
     123  struct tr_peerIo * io;
     124  struct peer_atom * atom;
     125
     126  /** how complete the peer's copy of the torrent is. [0.0...1.0] */
     127  float progress;
     128
     129  struct tr_bitfield blame;
     130  struct tr_bitfield have;
     131
     132  /* the client name.
     133     For BitTorrent peers, this is the app name derived from the `v' string in LTEP's handshake dictionary */
     134  tr_quark client;
     135
     136  time_t chokeChangedAt;
     137
     138  tr_recentHistory blocksSentToClient;
     139  tr_recentHistory blocksSentToPeer;
     140
     141  tr_recentHistory cancelsSentToClient;
     142  tr_recentHistory cancelsSentToPeer;
     143
     144  struct tr_peermsgs * msgs;
     145}
     146tr_peer;
    84147
    85148typedef void tr_peer_callback (struct tr_peer       * peer,
  • trunk/libtransmission/peer-mgr.h

    r13936 r13947  
    2424#endif
    2525
    26 #include "bitfield.h"
    27 #include "history.h"
    2826#include "net.h" /* tr_address */
    29 #include "peer-common.h" /* struct peer_request */
     27#include "peer-common.h"
    3028#include "quark.h"
    3129
     
    8179/* opaque forward declaration */
    8280struct peer_atom;
    83 
    84 /**
    85  * State information about a connected peer.
    86  *
    87  * @see struct peer_atom
    88  * @see tr_peermsgs
    89  */
    90 typedef struct tr_peer
    91 {
    92   bool peerIsChoked;
    93   bool peerIsInterested;
    94   bool clientIsChoked;
    95   bool clientIsInterested;
    96   bool doPurge;
    97 
    98   /* number of bad pieces they've contributed to */
    99   uint8_t strikes;
    100 
    101   uint8_t encryption_preference;
    102   tr_port dht_port;
    103 
    104   /* how many requests the peer has made that we haven't responded to yet */
    105   int pendingReqsToClient;
    106 
    107   /* how many requests we've made and are currently awaiting a response for */
    108   int pendingReqsToPeer;
    109 
    110   struct tr_peerIo * io;
    111   struct peer_atom * atom;
    112 
    113   struct tr_bitfield blame;
    114   struct tr_bitfield have;
    115 
    116   /** how complete the peer's copy of the torrent is. [0.0...1.0] */
    117   float progress;
    118 
    119   /* the client name from the `v' string in LTEP's handshake dictionary */
    120   tr_quark client;
    121 
    122   time_t chokeChangedAt;
    123 
    124   tr_recentHistory blocksSentToClient;
    125   tr_recentHistory blocksSentToPeer;
    126 
    127   tr_recentHistory cancelsSentToClient;
    128   tr_recentHistory cancelsSentToPeer;
    129 
    130   struct tr_peermsgs * msgs;
    131 }
    132 tr_peer;
    13381
    13482void tr_peerConstruct (struct tr_peer * peer);
  • trunk/libtransmission/peer-msgs.c

    r13900 r13947  
    177177    uint16_t        pexCount;
    178178    uint16_t        pexCount6;
     179
     180    tr_port         dht_port;
    179181
    180182    size_t          metadata_size_hint;
     
    14671469        case BT_PORT:
    14681470            dbgmsg (msgs, "Got a BT_PORT");
    1469             tr_peerIoReadUint16 (msgs->peer->io, inbuf, &msgs->peer->dht_port);
    1470             if (msgs->peer->dht_port > 0)
     1471            tr_peerIoReadUint16 (msgs->peer->io, inbuf, &msgs->dht_port);
     1472            if (msgs->dht_port > 0)
    14711473                tr_dhtAddNode (getSession (msgs),
    14721474                               tr_peerAddress (msgs->peer),
    1473                                msgs->peer->dht_port, 0);
     1475                               msgs->dht_port, 0);
    14741476            break;
    14751477
Note: See TracChangeset for help on using the changeset viewer.