Skip to content

Commit d4078b4

Browse files
committed
Style, clean out debug writes.
1 parent f7efb9c commit d4078b4

1 file changed

Lines changed: 8 additions & 32 deletions

File tree

include/bitcoin/database/impl/query/merkle.ipp

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -122,39 +122,27 @@ hash_digest CLASS::partial_subroot(hashes&& tree, size_t span) NOEXCEPT
122122
if (tree.empty() || tree.size() > span)
123123
return {};
124124

125+
// Zero depth implies single tree element, which is the root.
125126
using namespace system;
126127
const auto depth = ceilinged_log2(span);
127-
////std::cout << "depth : " << depth << std::endl;
128-
129-
// Zero depth implies single tree element, which is the root.
130128
if (is_zero(depth))
131129
return tree.front();
132130

133131
// merkle_root() treats a single hash as top/complete, but for a partial
134132
// depth subtree, an odd leaf (including a single) requires duplication.
135133
if (is_odd(tree.size()))
136-
{
137134
tree.push_back(tree.back());
138-
////std::cout << "evened : " << tree.size() << std::endl;
139-
}
140135

141136
// Log2 of the evened breadth gives the elevation by merkle_root.
142-
auto partial = ceilinged_log2(tree.size());
143-
144137
// Partial cannot exceed depth, since tree.size() <= span (a power of 2).
138+
auto partial = ceilinged_log2(tree.size());
145139
if (is_subtract_overflow(depth, partial))
146140
return {};
147141

148-
// Elevate hashes to partial level.
149-
////std::cout << "merkled : " << tree.size() << std::endl;
142+
// Elevate hashes to partial level, and then from partial to depth.
150143
auto hash = merkle_root(std::move(tree));
151-
152-
// Elevate hashes from partial to depth.
153144
for (; partial < depth; ++partial)
154-
{
155145
hash = sha256::double_hash(hash, hash);
156-
////std::cout << "hashed : " << partial << std::endl;
157-
}
158146

159147
return hash;
160148
}
@@ -166,19 +154,13 @@ code CLASS::get_merkle_subroots(hashes& roots, size_t waypoint) const NOEXCEPT
166154
const auto span = interval_span();
167155
BC_ASSERT(!is_zero(span));
168156

169-
// Roots is even-size-except-one-reserved for merkle root push.
157+
using namespace system;
170158
const auto leafs = add1(waypoint);
171-
const auto limit = system::ceilinged_divide(leafs, span);
159+
const auto limit = ceilinged_divide(leafs, span);
172160
const auto count = limit + to_int<size_t>(!is_one(limit) && is_odd(limit));
173-
roots.reserve(count);
174161

175-
//// const auto config = system::ceilinged_log2(span);
176-
////std::cout << "==================================" << std::endl;
177-
////std::cout << "config : " << config << std::endl;
178-
////std::cout << "span : " << span << std::endl;
179-
////std::cout << "leaves : " << leaves << std::endl;
180-
////std::cout << "waypoint : " << waypoint << std::endl;
181-
////std::cout << "reserve : " << count << std::endl;
162+
// Roots is even-size-except-one-reserved for merkle root push.
163+
roots.reserve(count);
182164

183165
// Either all subroots elevated to same level, or there is a single root.
184166
for (size_t first{}; first < leafs; first += span)
@@ -191,26 +173,20 @@ code CLASS::get_merkle_subroots(hashes& roots, size_t waypoint) const NOEXCEPT
191173
auto interval = get_confirmed_interval(last);
192174
if (!interval.has_value()) return error::merkle_interval;
193175
roots.push_back(std::move(interval.value()));
194-
////std::cout << "A cached subroot : ";
195176
}
196177
else if (is_zero(first))
197178
{
198179
// Single hash, is the complete merkle root.
199180
auto complete = get_confirmed_hashes(zero, size);
200-
roots.push_back(system::merkle_root(std::move(complete)));
201-
////std::cout << "The merkle root : ";
181+
roots.push_back(merkle_root(std::move(complete)));
202182
}
203183
else
204184
{
205185
// Roots is even-size-except-one-reserved for merkle root push.
206186
auto partial = get_confirmed_hashes(first, size);
207187
if (partial.empty()) return error::merkle_hashes;
208188
roots.push_back(partial_subroot(std::move(partial), span));
209-
////std::cout << "Computed subroot : ";
210189
}
211-
212-
////std::cout << first << " - " << last
213-
//// << " [" << system::encode_hash(roots.back()) << "]" << std::endl;
214190
}
215191

216192
return error::success;

0 commit comments

Comments
 (0)