/* * Generates UDP key for specified IP address */ CID Utils::getUdpKey(const string& targetIp) { CID myUdpKey = CID(SETTING(DHT_KEY)); TigerTree th; th.update(myUdpKey.data(), sizeof(CID)); th.update(targetIp.c_str(), targetIp.size()); return CID(th.finalize()); }
Info run(const string& path) { // adapted from dcpp::HashManager File f { path, File::READ, File::OPEN }; auto size = f.getSize(); f.close(); static const int64_t MIN_BLOCK_SIZE = 64 * 1024; auto bs = std::max(TigerTree::calcBlockSize(size, 10), MIN_BLOCK_SIZE); TigerTree tt { bs }; auto start = GET_TICK(); FileReader(true).read(path, [&](const void* buf, size_t n) -> bool { tt.update(buf, n); return true; }); tt.finalize(); auto end = GET_TICK(); double speed = 0.0; if(end > start) { speed = static_cast<double>(size) * 1000.0 / static_cast<double>(end - start); } Info ret { tt.getRoot().toBase32(), end - start, speed }; return ret; }