From 334c6e4bbb97a4c0656e1b07c3e6a565f68eae2b Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Fri, 28 Nov 2008 22:21:10 +0000 Subject: The BIG refactoring [tm]. Too many changes to count them. If it doesn't suite you, revert to last version. --- ot_vector.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'ot_vector.h') diff --git a/ot_vector.h b/ot_vector.h index 1d42dd0..37135e7 100644 --- a/ot_vector.h +++ b/ot_vector.h @@ -12,21 +12,23 @@ #define OT_VECTOR_SHRINK_THRESH 4 #define OT_VECTOR_SHRINK_RATIO 2 +#define OT_PEER_BUCKET_MINCOUNT 512 +#define OT_PEER_BUCKET_MAXCOUNT 256 + typedef struct { void *data; size_t size; size_t space; } ot_vector; -void *binary_search( const void * const key, const void * base, const size_t member_count, const size_t member_size, - size_t compare_size, int *exactmatch ); -void *vector_find_or_insert( ot_vector *vector, void *key, size_t member_size, size_t compare_size, int *exactmatch ); - -int vector_remove_peer( ot_vector *vector, ot_peer *peer, int hysteresis ); -void vector_remove_torrent( ot_vector *vector, ot_torrent *match ); +void *binary_search( const void * const key, const void * base, const size_t member_count, const size_t member_size, + size_t compare_size, int *exactmatch ); +void *vector_find_or_insert( ot_vector *vector, void *key, size_t member_size, size_t compare_size, int *exactmatch ); +ot_peer *vector_find_or_insert_peer( ot_vector *vector, ot_peer *peer, int *exactmatch ); -#ifdef _DEBUG_VECTOR -size_t vector_info( char * reply ); -#endif +int vector_remove_peer( ot_vector *vector, ot_peer *peer ); +void vector_remove_torrent( ot_vector *vector, ot_torrent *match ); +void vector_redistribute_buckets( ot_peerlist * peer_list ); +void vector_fixup_peers( ot_vector * vector ); #endif -- cgit v1.2.3