* Using SocketAddress instead of PeerInfo in Tracker*, unconnected

peers and HandshakeManager. Some other address releated code was
cleaned up.

* Made a seperate AvailableList class for unconnected peers. Using the
tracker success signal to call a function in ConnectionList that
removes already connected peers from the list.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@514 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-08-03 18:50:36 +00:00
parent 91a6950c01
commit e5aad7ed6a
4 changed files with 43 additions and 5 deletions
+40 -2
View File
@@ -72,6 +72,8 @@ accumulate(Type& t, Ftor f) {
template <typename Type, typename Ftor>
struct _equal {
typedef bool result_type;
_equal(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
@@ -91,6 +93,8 @@ equal(Type t, Ftor f) {
template <typename Type, typename Ftor>
struct _less {
typedef bool result_type;
_less(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
@@ -110,6 +114,8 @@ less(Type t, Ftor f) {
template <typename Type, typename Ftor>
struct _greater {
typedef bool result_type;
_greater(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
@@ -129,6 +135,8 @@ greater(Type t, Ftor f) {
template <typename Type, typename Ftor>
struct _less_equal {
typedef bool result_type;
_less_equal(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
@@ -148,6 +156,8 @@ less_equal(Type t, Ftor f) {
template <typename Type, typename Ftor>
struct _greater_equal {
typedef bool result_type;
_greater_equal(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
@@ -166,10 +176,12 @@ greater_equal(Type t, Ftor f) {
}
template <typename Src, typename Dest>
struct _on : public std::unary_function<typename Src::argument_type, typename Dest::result_type> {
struct _on : public std::unary_function<typename Src::argument_type, typename Dest::result_type> {
typedef typename Dest::result_type result_type;
_on(Src s, Dest d) : m_dest(d), m_src(s) {}
typename Dest::result_type operator () (typename reference_fix<typename Src::argument_type>::type arg) {
result_type operator () (typename reference_fix<typename Src::argument_type>::type arg) {
return m_dest(m_src(arg));
}
@@ -260,6 +272,32 @@ bind1st(const Operation& op, const Type& val) {
return bind1st_t<Operation>(op, val);
}
template <typename Operation>
class bind2nd_t : public std::unary_function<typename Operation::first_argument_type,
typename Operation::result_type> {
protected:
typedef typename reference_fix<typename Operation::first_argument_type>::type argument_type;
typedef typename reference_fix<typename Operation::second_argument_type>::type value_type;
Operation m_op;
value_type m_value;
public:
bind2nd_t(const Operation& op, const value_type v) :
m_op(op), m_value(v) {}
typename Operation::result_type
operator () (const argument_type arg) {
return m_op(arg, m_value);
}
};
template <typename Operation, typename Type>
inline bind2nd_t<Operation>
bind2nd(const Operation& op, const Type& val) {
return bind2nd_t<Operation>(op, val);
}
}
#endif
+1 -1
View File
@@ -102,7 +102,7 @@ WindowPeerList::redraw() {
m_canvas->print(x, y, "%.1f", (double)p.get_peer_rate().rate() / 1024); x += 7;
m_canvas->print(x, y, "%c/%c%c/%c%c",
p.is_incoming() ? 'R' : 'L',
p.is_incoming() ? 'r' : 'l',
p.get_remote_choked() ? 'c' : 'u',
p.get_remote_interested() ? 'i' : 'n',
p.get_local_choked() ? 'c' : 'u',
+1 -1
View File
@@ -76,7 +76,7 @@ WindowStatusbar::redraw() {
buf,
(double)torrent::get_write_rate().rate() / 1024.0,
(double)torrent::get_read_rate().rate() / 1024.0,
!torrent::get_address().empty() ? torrent::get_address().c_str() : "<default>",
!torrent::get_local_address().empty() ? torrent::get_local_address().c_str() : "<default>",
(int)torrent::get_listen_port(),
!torrent::get_bind_address().empty() ? (" Bind: " + torrent::get_bind_address()).c_str() : "");
+1 -1
View File
@@ -194,7 +194,7 @@ apply_bind(ui::Control* m, const std::string& arg) {
void
apply_ip(ui::Control* m, const std::string& arg) {
torrent::set_address(arg);
torrent::set_local_address(arg);
}
// The arg string *must* have been checked with validate_port_range