Changeset 13932


Ignore:
Timestamp:
Feb 2, 2013, 5:31:43 AM (8 years ago)
Author:
jordan
Message:

(libT) remove pointless tr_session.peer_id variable

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r13868 r13932  
    195195  const uint8_t * torrentHash = tr_cryptoGetTorrentHash (handshake->crypto);
    196196  const tr_torrent * tor = tr_torrentFindFromHash (handshake->session, torrentHash);
    197   const uint8_t * peer_id = tor && *tor->peer_id ? tor->peer_id : tr_getPeerId (handshake->session);
     197  const uint8_t * peer_id = tor->peer_id;
    198198
    199199  memcpy (walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN);
     
    273273
    274274  tor = tr_torrentFindFromHash (handshake->session, hash);
    275   tor_peer_id = tor ? tor->peer_id : tr_getPeerId (handshake->session);
     275  tor_peer_id = tor->peer_id;
    276276  if (!memcmp (peer_id, tor_peer_id, PEER_ID_LEN))
    277277    {
     
    686686            struct evbuffer * inbuf)
    687687{
    688   bool peerIsGood;
     688  bool connected_to_self;
    689689  char client[128];
     690  uint8_t peer_id[PEER_ID_LEN];
    690691  tr_torrent * tor;
    691   const uint8_t * tor_peer_id;
    692   uint8_t peer_id[PEER_ID_LEN];
    693692
    694693  if (evbuffer_get_length (inbuf) < PEER_ID_LEN)
     
    705704  /* if we've somehow connected to ourselves, don't keep the connection */
    706705  tor = tr_torrentFindFromHash (handshake->session, tr_peerIoGetTorrentHash (handshake->io));
    707   tor_peer_id = tor ? tor->peer_id : tr_getPeerId (handshake->session);
    708   peerIsGood = memcmp (peer_id, tor_peer_id, PEER_ID_LEN) != 0;
    709   dbgmsg (handshake, "isPeerGood == %d", (int)peerIsGood);
    710   return tr_handshakeDone (handshake, peerIsGood);
     706  connected_to_self = (tor != NULL) && !memcmp (peer_id, tor->peer_id, PEER_ID_LEN);
     707
     708  return tr_handshakeDone (handshake, !connected_to_self);
    711709}
    712710
  • trunk/libtransmission/session.c

    r13868 r13932  
    593593    session->magicNumber = SESSION_MAGIC_NUMBER;
    594594    tr_bandwidthConstruct (&session->bandwidth, session, NULL);
    595     tr_peerIdInit (session->peer_id);
    596595    tr_variantInitList (&session->removedTorrents, 0);
    597596
  • trunk/libtransmission/session.h

    r13711 r13932  
    224224    struct tr_bindinfo         * public_ipv4;
    225225    struct tr_bindinfo         * public_ipv6;
    226 
    227     uint8_t peer_id[PEER_ID_LEN+1];
    228226};
    229227
     
    232230{
    233231    return session->public_peer_port;
    234 }
    235 
    236 static inline const uint8_t*
    237 tr_getPeerId (tr_session * session)
    238 {
    239     return session->peer_id;
    240232}
    241233
Note: See TracChangeset for help on using the changeset viewer.