confirmation for local items only

This commit is contained in:
Denis Ryabov 2014-07-08 17:01:53 +04:00
parent 785d05f10c
commit 683f55f8d2
2 changed files with 4 additions and 6 deletions

View File

@ -121,12 +121,12 @@ struct torrent_entry
struct dht_storage_item
{
// FIXME: optimize so bdecode is not needed all the time
dht_storage_item() : p(), sig_p(), sig_user(), local_add_time(0), confirmed(false), next_refresh_time(0) {}
dht_storage_item() : p(), sig_p(), sig_user(), local_add_time(0), confirmed(true), next_refresh_time(0) {}
dht_storage_item(std::string const &_p, lazy_entry const *_sig_p, lazy_entry const *_sig_user)
: p(_p), sig_p(_sig_p->string_value()), sig_user(_sig_user->string_value()),
local_add_time(0), confirmed(false), next_refresh_time(0) {}
local_add_time(0), confirmed(true), next_refresh_time(0) {}
dht_storage_item(std::string const &_p, std::string const &_sig_p, std::string const &_sig_user)
: p(_p), sig_p(_sig_p), sig_user(_sig_user), local_add_time(0), confirmed(false), next_refresh_time(0) {}
: p(_p), sig_p(_sig_p), sig_user(_sig_user), local_add_time(0), confirmed(true), next_refresh_time(0) {}
std::string p;
std::string sig_p;
std::string sig_user;

View File

@ -474,6 +474,7 @@ void node_impl::putDataSigned(std::string const &username, std::string const &re
dht_storage_item item(str_p, sig_p, sig_user);
item.local_add_time = time(NULL);
item.confirmed = false;
std::vector<char> vbuf;
bencode(std::back_inserter(vbuf), p["v"]);
std::pair<char const*, int> bufv = std::make_pair(vbuf.data(), vbuf.size());
@ -749,9 +750,6 @@ void node_impl::load_storage(entry const* e) {
entry const *confirmed( j->find_key("confirmed") );
if(confirmed) {
item.confirmed = (bool) confirmed->integer();
} else {
// compatibility with twister 0.9.22 and below
item.confirmed = true;
}
// just for printf for now