libktorrent
2.2.0
src
dht
announcetask.h
1
/***************************************************************************
2
* Copyright (C) 2005 by Joris Guisson *
3
* joris.guisson@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
#ifndef DHTANNOUNCETASK_H
21
#define DHTANNOUNCETASK_H
22
23
24
#include "kbucket.h"
25
#include "task.h"
26
27
namespace
dht
28
{
29
class
Database;
30
31
class
KBucketEntryAndToken :
public
KBucketEntry
32
{
33
QByteArray token;
34
public
:
35
KBucketEntryAndToken() {}
36
KBucketEntryAndToken(
const
KBucketEntry
& e,
const
QByteArray & token)
37
:
KBucketEntry
(e), token(token) {}
38
~KBucketEntryAndToken()
override
{}
39
40
const
QByteArray & getToken()
const
41
{
42
return
token;
43
}
44
};
45
49
class
AnnounceTask
:
public
Task
50
{
51
public
:
52
AnnounceTask
(
Database
* db,
53
RPCServer
* rpc,
54
Node
* node,
55
const
dht::Key
& info_hash,
56
bt::Uint16 port,
57
QObject* parent);
58
~
AnnounceTask
()
override
;
59
60
void
callFinished
(
RPCCall
* c, RPCMsg::Ptr rsp)
override
;
61
void
callTimeout
(
RPCCall
* c)
override
;
62
void
update
()
override
;
63
70
bool
takeItem
(
DBItem
& item);
71
72
private
:
73
void
handleNodes(
const
QByteArray & nodes,
int
ip_version);
74
75
private
:
76
dht::Key
info_hash;
77
bt::Uint16 port;
78
std::set<KBucketEntryAndToken> answered;
// nodes which have answered with values
79
KBucketEntrySet
answered_visited;
// nodes which have answered with values which have been visited
80
Database
* db;
81
DBItemList returned_items;
82
};
83
84
}
85
86
#endif
dht::AnnounceTask::callTimeout
void callTimeout(RPCCall *c) override
dht::AnnounceTask::takeItem
bool takeItem(DBItem &item)
dht::Key
Key in the distributed hash table.
Definition:
key.h:57
dht::Database
Definition:
database.h:97
dht::AnnounceTask::update
void update() override
dht::Task
Definition:
task.h:47
dht::Node
Definition:
node.h:51
dht::RPCServer
Definition:
rpcserver.h:46
dht::DBItem
Definition:
database.h:63
dht::KBucketEntry::KBucketEntry
KBucketEntry()
dht::AnnounceTask::callFinished
void callFinished(RPCCall *c, RPCMsg::Ptr rsp) override
dht::KBucketEntrySet
Definition:
kbucketentry.h:130
dht::RPCCall
Definition:
rpccall.h:78
dht::AnnounceTask
Definition:
announcetask.h:68
Generated by
1.8.18