Changeset 11641


Ignore:
Timestamp:
Jan 6, 2011, 3:12:12 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) very minor code cleanup -- use an enum instead of magic numbers, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/webseed.c

    r11632 r11641  
    11/*
    2  * This file Copyright (C) 2008-2010 Mnemosyne LLC
     2 * This file Copyright (C) Mnemosyne LLC
    33 *
    44 * This file is licensed by the GPL version 2. Works owned by the
     
    5454};
    5555
     56enum
     57{
     58    TR_IDLE_TIMER_MSEC = 2000
     59};
     60
    5661static void
    5762webseed_free( struct tr_webseed * w )
     
    7075***/
    7176
    72 static const tr_peer_event blankEvent = { 0, 0, 0, 0, 0.0f, 0, 0, 0 };
     77static const tr_peer_event blank_event = { 0, 0, 0, 0, 0.0f, 0, 0, 0 };
    7378
    7479static void
     
    8085
    8186static void
    82 fireClientGotBlock( tr_torrent * tor, tr_webseed * w, tr_block_index_t block )
    83 {
    84     tr_peer_event e = blankEvent;
     87fire_client_got_block( tr_torrent * tor, tr_webseed * w, tr_block_index_t block )
     88{
     89    tr_peer_event e = blank_event;
    8590    e.pieceIndex = tr_torBlockPiece( tor, block );
    8691    e.offset = tor->blockSize * block - tor->info.pieceSize * e.pieceIndex;
     
    9196
    9297static void
    93 fireClientGotData( tr_webseed * w, uint32_t length )
    94 {
    95     tr_peer_event e = blankEvent;
     98fire_client_got_data( tr_webseed * w, uint32_t length )
     99{
     100    tr_peer_event e = blank_event;
    96101    e.eventType = TR_PEER_CLIENT_GOT_DATA;
    97102    e.length = length;
     
    114119    {
    115120        tr_rcTransferred( &w->download_rate, info->n_added );
    116         fireClientGotData( w, info->n_added );
     121        fire_client_got_data( w, info->n_added );
    117122    }
    118123}
     
    153158            task->piece_index = tr_torBlockPiece( tor, b );
    154159            task->piece_offset = ( tor->blockSize * b )
    155                                    - ( tor->info.pieceSize * task->piece_index );
     160                                - ( tor->info.pieceSize * task->piece_index );
    156161            task->length = tr_torBlockCountBytes( tor, b );
    157162            task->content = evbuffer_new( );
     
    190195                                t->piece_index, t->piece_offset, t->length,
    191196                                evbuffer_pullup( t->content, -1 ) );
    192             fireClientGotBlock( tor, w, t->block );
     197            fire_client_got_block( tor, w, t->block );
    193198
    194199            tr_list_remove_data( &w->tasks, t );
     
    231236                                    + evbuffer_get_length( t->content );
    232237        const tr_piece_index_t step_piece = total_offset / inf->pieceSize;
    233         const uint32_t step_piece_offset = total_offset - ( inf->pieceSize * step_piece );
     238        const uint32_t step_piece_offset
     239                               = total_offset - ( inf->pieceSize * step_piece );
    234240
    235241        tr_file_index_t file_index;
     
    275281    tr_webseed * w = vw;
    276282    on_idle( w );
    277     tr_timerAddMsec( w->timer, 1000 );
     283    tr_timerAddMsec( w->timer, TR_IDLE_TIMER_MSEC );
    278284}
    279285
     
    288294
    289295    peer->peerIsChoked = TRUE;
    290     peer->peerIsInterested = FALSE;
    291     peer->clientIsChoked = FALSE;
    292     peer->clientIsChoked = FALSE;
    293296    peer->clientIsInterested = !tr_torrentIsSeed( tor );
    294297    tr_bitsetConstructor( &peer->have, tor->info.pieceCount );
     
    306309    tr_rcConstruct( &w->download_rate );
    307310    w->timer = evtimer_new( w->session->event_base, webseed_timer_func, w );
    308     tr_timerAddMsec( w->timer, 1000 );
     311    tr_timerAddMsec( w->timer, TR_IDLE_TIMER_MSEC );
    309312    return w;
    310313}
Note: See TracChangeset for help on using the changeset viewer.