diff --git a/src/main.cpp b/src/main.cpp
index 2d9fca5..949ff24 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,7 +15,6 @@
* along with ducktorrent. If not, see .
*/
-#include "parser.hpp"
#include "torrent_read.hpp"
#include
@@ -25,6 +24,7 @@
#include
#include
#include
+#include
namespace {
SHA1::MessageDigest to_hash160_digest (const std::array& arr) {
@@ -53,8 +53,7 @@ int main(int argc, const char* argv[]) {
torrent.print(std::cout);
- const auto& values = torrent.parsed_values();
- auto hashes = duck::collect_hashes(values);
+ auto hashes = duck::group_torrent_hashes(torrent);
std::cout << "Got " << hashes.size() << " hashes\n";
const auto file_count = torrent.read_file_count();
diff --git a/src/parser.cpp b/src/parser.cpp
index 63b947d..302d84a 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -20,7 +20,6 @@
#endif
#include "parser.hpp"
-#include "visitors/find_t_visitor.hpp"
#include
#include
@@ -163,35 +162,4 @@ std::vector parse_torrent (std::string_view binary_data) {
return retval;
}
-
-std::vector> collect_hashes (std::string_view hashes) {
- typedef std::array array_type;
-
- if (hashes.empty())
- return {};
-
- constexpr std::size_t hash_size = 20;
- constexpr std::size_t uint_count = std::tuple_size();
- static_assert(sizeof(array_type::value_type) * uint_count == hash_size);
-
- if (hashes.size() % hash_size != 0)
- throw std::runtime_error("Bad pieces array size " + std::to_string(hashes.size()));
-
- std::vector retval(hashes.size() / hash_size);
- const char* src = hashes.data();
- for (std::size_t z = 0; z < retval.size(); ++z, src+=hash_size) {
- //std::copy_n(src, hash_size, reinterpret_cast(retval[z].data()));
- for (std::size_t n = 0; n < uint_count; ++n) {
- char* const out_uint = reinterpret_cast(retval[z].data() + n);
- for (std::size_t u = 0; u < sizeof(std::uint32_t); ++u) {
- out_uint[u] = src[n * sizeof(std::uint32_t) + sizeof(std::uint32_t) - u - 1];
- }
- }
- }
- return retval;
-}
-
-std::vector> collect_hashes (const std::vector& values) {
- return collect_hashes(find_string("/info/pieces", values));
-}
} //namespace duck
diff --git a/src/parser.hpp b/src/parser.hpp
index 8800092..071629d 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -21,8 +21,6 @@
#include
#include