Skip to content

Commit f8d3333

Browse files
committed
Use namespaces, error_category::contains(ec), logging.
1 parent 1d5a9ec commit f8d3333

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

src/chasers/chaser_validate.cpp

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void chaser_validate::do_bump(height_t) NOEXCEPT
191191

192192
if (bypass && !filter_)
193193
{
194-
complete_block(error::success, link, height);
194+
complete_block(database::error::success, link, height);
195195
}
196196
else
197197
{
@@ -242,8 +242,8 @@ void chaser_validate::validate_block(const header_link& link,
242242
POST(tracked_complete_block, ec, link, ctx.height);
243243
}
244244

245-
code chaser_validate::populate(bool bypass, const system::chain::block& block,
246-
const system::chain::context& ctx) NOEXCEPT
245+
code chaser_validate::populate(bool bypass, const chain::block& block,
246+
const chain::context& ctx) NOEXCEPT
247247
{
248248
const auto& query = archive();
249249

@@ -262,30 +262,63 @@ code chaser_validate::populate(bool bypass, const system::chain::block& block,
262262
return system::error::missing_previous_output;
263263
}
264264

265-
return error::success;
265+
return system::error::success;
266266
}
267267

268-
code chaser_validate::validate(bool bypass, const system::chain::block& block,
269-
const database::header_link& link,
270-
const system::chain::context& ctx) NOEXCEPT
268+
code chaser_validate::validate(bool bypass, const chain::block& block,
269+
const database::header_link& link, const chain::context& ctx) NOEXCEPT
271270
{
272271
code ec{};
273272
if (bypass)
274273
return ec;
275274

275+
///////////////////////////////////////////////////////////////////////////////
276+
////if (!block.is_segregated())
277+
////{
278+
//// block.clear_hash_cache(true);
279+
//// if (block.is_invalid_witness_commitment())
280+
//// return error::validate6;
281+
////}
282+
////else
283+
////{
284+
//// block.clear_hash_cache(false);
285+
//// if (block.is_invalid_merkle_root())
286+
//// return error::validate7;
287+
////}
288+
///////////////////////////////////////////////////////////////////////////////
289+
290+
///////////////////////////////////////////////////////////////////////////
291+
////if (ctx.is_enabled(chain::flags::bip141_rule) && block.is_segregated())
292+
////{
293+
//// fire(events::snapshot_span, block.segregated());
294+
////}
295+
///////////////////////////////////////////////////////////////////////////
296+
276297
auto& query = archive();
277298

278299
if ((ec = block.accept(ctx, subsidy_interval_, initial_subsidy_)))
279-
return ec;
300+
{
301+
///////////////////////////////////////////////////////////////////////
302+
// Allow failure.
303+
LOGR("block.accept [" << ctx.height << "] " << ec.message());
304+
return error::success;
305+
///////////////////////////////////////////////////////////////////////
306+
}
280307

281308
if ((ec = block.connect(ctx)))
282-
return ec;
309+
{
310+
///////////////////////////////////////////////////////////////////////
311+
// Allow failure.
312+
LOGR("block.connect [" << ctx.height << "] " << ec.message());
313+
return error::success;
314+
///////////////////////////////////////////////////////////////////////
315+
}
283316

284317
if (!query.set_prevouts(link, block))
285-
return error::validate6;
318+
return error::validate8;
286319

287320
if (!query.set_block_valid(link, block.fees()))
288-
return error::validate7;
321+
return error::validate9;
289322

290323
return ec;
291324
}
@@ -307,15 +340,9 @@ void chaser_validate::complete_block(const code& ec, const header_link& link,
307340

308341
if (ec)
309342
{
310-
// Differentiated fault codes for troubleshooting.
311-
if (ec == error::validate1 ||
312-
ec == error::validate2 ||
313-
ec == error::validate3 ||
314-
ec == error::validate4 ||
315-
ec == error::validate5 ||
316-
ec == error::validate6 ||
317-
ec == error::validate7)
343+
if (node::error::error_category::contains(ec))
318344
{
345+
LOGR("Validate fault [" << height << "] " << ec.message());
319346
fault(ec);
320347
return;
321348
}

0 commit comments

Comments
 (0)