@@ -812,92 +812,6 @@ BOOST_AUTO_TEST_CASE(block__merkle_branch__maximum_non_overflow__expected)
812812 BOOST_REQUIRE_EQUAL (branch.back ().width , power2 (sub1 (sub1 (bits<size_t >))));
813813}
814814
815- // TODO: unused.
816- hash_digest get_hash (size_t /* height */ ) NOEXCEPT
817- {
818- return {};
819- }
820-
821- // TODO: database query, limited to interval heights, txs table.
822- hash_digest get_interval (size_t /* last */ ) NOEXCEPT
823- {
824- return {};
825- }
826-
827- // TODO: database query, chase ancestry.
828- hashes get_segment (size_t first, size_t count) NOEXCEPT
829- {
830- BC_ASSERT (!is_add_overflow (first, count));
831-
832- hashes out{};
833- out.reserve (count);
834- for (auto height = first; height < (first + count); ++height)
835- out.push_back (get_hash (height));
836-
837- return out;
838- }
839-
840- void push (hashes& branch, hashes&& hashes, size_t first,
841- size_t count) NOEXCEPT
842- {
843- for (const auto & row: block::merkle_branch (first, count))
844- {
845- const auto it = std::next (hashes.begin (), row.sibling * row.width );
846- const auto mover = std::make_move_iterator (it);
847- branch.push_back (merkle_root ({ mover, std::next (mover, row.width ) }));
848- }
849- }
850-
851- // Compute branch for target given checkpoint and merkle tree (hashes).
852- hashes compute_merkle_proof (hashes roots, size_t checkpoint,
853- size_t target) NOEXCEPT
854- {
855- constexpr auto depth = 11u ;
856- constexpr auto size = power2 (depth);
857- const auto local = target % size;
858- const auto index = target / size;
859- const auto start = index * size;
860- const auto end = std::min (sub1 (start + size), checkpoint);
861- const auto length = add1 (end - start);
862-
863- hashes branch{};
864- branch.reserve (ceilinged_log2 (length) + ceilinged_log2 (roots.size ()));
865- push (branch, get_segment (start, length), local, length);
866- push (branch, std::move (roots), index, roots.size ());
867- return branch;
868- }
869-
870- hashes compute_merkle_roots (size_t checkpoint) NOEXCEPT
871- {
872- constexpr auto depth = 11u ;
873- constexpr auto size = power2 (depth);
874- const auto total = add1 (checkpoint);
875-
876- hashes roots{};
877- roots.reserve (ceilinged_divide (total, size));
878- for (size_t start{}; start < total; start += size)
879- {
880- const auto end = std::min (sub1 (start + size), checkpoint);
881- const auto length = add1 (end - start);
882- roots.push_back (length == size ? get_interval (end) :
883- merkle_root (get_segment (start, length)));
884- }
885-
886- return roots;
887- }
888-
889- // Computes root and branch (proof) for a block height up to a checkpoint.
890- std::pair<hash_digest, hashes> compute_root_and_branch (size_t checkpoint,
891- size_t height) NOEXCEPT
892- {
893- BC_ASSERT (height <= checkpoint);
894-
895- auto roots = compute_merkle_roots (checkpoint);
896- auto proof = compute_merkle_proof (roots, checkpoint, height);
897- auto root = merkle_root (std::move (roots));
898- return { std::move (root), std::move (proof) };
899- }
900-
901815// is_overweight
902816// is_invalid_coinbase_script
903817// is_hash_limit_exceeded
0 commit comments