forked from premiere/premiere-libtorrent
Boolean simplifications (oct 13th 2016) (#1211)
boolean simplifications
This commit is contained in:
parent
8839722bec
commit
9cdf0ee50c
|
@ -180,9 +180,7 @@ bool node::verify_token(string_view token, sha1_hash const& info_hash
|
||||||
h2.update(reinterpret_cast<char const*>(&m_secret[1]), sizeof(m_secret[1]));
|
h2.update(reinterpret_cast<char const*>(&m_secret[1]), sizeof(m_secret[1]));
|
||||||
h2.update(info_hash);
|
h2.update(info_hash);
|
||||||
h = h2.final();
|
h = h2.final();
|
||||||
if (std::equal(token.begin(), token.end(), reinterpret_cast<char*>(&h[0])))
|
return std::equal(token.begin(), token.end(), reinterpret_cast<char*>(&h[0]));
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string node::generate_token(udp::endpoint const& addr
|
std::string node::generate_token(udp::endpoint const& addr
|
||||||
|
|
|
@ -70,9 +70,7 @@ namespace
|
||||||
, node_id const& id, address const& addr)
|
, node_id const& id, address const& addr)
|
||||||
{
|
{
|
||||||
// only when the node_id pass the verification, add it to routing table.
|
// only when the node_id pass the verification, add it to routing table.
|
||||||
if (settings.enforce_node_id && !verify_id(id, addr)) return false;
|
return !settings.enforce_node_id || verify_id(id, addr);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,8 +435,7 @@ bool routing_table::add_node(node_entry const& e)
|
||||||
// be a bug in the bucket splitting logic, or there may be someone
|
// be a bug in the bucket splitting logic, or there may be someone
|
||||||
// playing a prank on us, spoofing node IDs.
|
// playing a prank on us, spoofing node IDs.
|
||||||
s = add_node_impl(e);
|
s = add_node_impl(e);
|
||||||
if (s == node_added) return true;
|
return s == node_added;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the new bucket still has too many nodes in it, we need to keep
|
// if the new bucket still has too many nodes in it, we need to keep
|
||||||
|
@ -1102,8 +1099,7 @@ void routing_table::heard_about(node_id const& id, udp::endpoint const& ep)
|
||||||
// id)
|
// id)
|
||||||
bool routing_table::node_seen(node_id const& id, udp::endpoint const& ep, int rtt)
|
bool routing_table::node_seen(node_id const& id, udp::endpoint const& ep, int rtt)
|
||||||
{
|
{
|
||||||
if (!verify_node_address(m_settings, id, ep.address())) return false;
|
return verify_node_address(m_settings, id, ep.address()) && add_node(node_entry(id, ep, rtt, true));
|
||||||
return add_node(node_entry(id, ep, rtt, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fills the vector with the k nodes from our buckets that
|
// fills the vector with the k nodes from our buckets that
|
||||||
|
|
Loading…
Reference in New Issue