Skip to content

Commit 609b634

Browse files
committed
Update fault codes, balance confirmation threads.
1 parent 9b70385 commit 609b634

File tree

8 files changed

+157
-328
lines changed

8 files changed

+157
-328
lines changed

include/bitcoin/node/error.hpp

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,39 +53,52 @@ enum error_t : uint8_t
5353
suspended_service,
5454

5555
/// blockchain
56-
branch_error,
5756
orphan_block,
5857
orphan_header,
5958
duplicate_block,
6059
duplicate_header,
61-
////validation_bypass,
62-
////confirmation_bypass,
6360

64-
/// chasers
65-
set_block_unconfirmable,
66-
get_height,
67-
get_branch_work,
68-
get_is_strong,
69-
invalid_branch_point,
70-
pop_candidate,
71-
push_candidate,
72-
invalid_fork_point,
73-
get_candidate_chain_state,
74-
get_block,
75-
get_unassociated,
76-
get_fork_work,
77-
to_confirmed,
78-
pop_confirmed,
79-
get_block_confirmable,
80-
get_block_state,
81-
set_strong,
82-
set_unstrong,
83-
set_organized,
84-
set_block_confirmable,
85-
set_block_valid,
86-
node_confirm,
87-
node_validate,
88-
node_roll_back
61+
/// faults (terminal, code error and store corruption assumed)
62+
protocol1,
63+
header1,
64+
organize1,
65+
organize2,
66+
organize3,
67+
organize4,
68+
organize5,
69+
organize6,
70+
organize7,
71+
organize8,
72+
organize9,
73+
organize10,
74+
organize11,
75+
organize12,
76+
organize13,
77+
organize14,
78+
organize15,
79+
validate1,
80+
validate2,
81+
validate3,
82+
validate4,
83+
validate5,
84+
validate6,
85+
confirm1,
86+
confirm2,
87+
confirm3,
88+
confirm4,
89+
confirm5,
90+
confirm6,
91+
confirm7,
92+
confirm8,
93+
confirm9,
94+
confirm10,
95+
confirm11,
96+
confirm12,
97+
confirm13,
98+
confirm14,
99+
confirm15,
100+
confirm16,
101+
confirm17
89102
};
90103

91104
// No current need for error_code equivalence mapping.

include/bitcoin/node/impl/chasers/chaser_organize.ipp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ code CLASS::start() NOEXCEPT
5757

5858
if (!state_)
5959
{
60-
fault(error::get_candidate_chain_state);
61-
return error::get_candidate_chain_state;
60+
fault(error::organize1);
61+
return error::organize1;
6262
}
6363

6464
LOGN("Candidate top [" << system::encode_hash(state_->hash()) << ":"
@@ -205,14 +205,14 @@ void CLASS::do_organize(typename Block::cptr block,
205205

206206
if (!get_branch_work(work, branch_point, tree_branch, store_branch, header))
207207
{
208-
handler(fault(error::get_branch_work), height);
208+
handler(fault(error::organize2), height);
209209
return;
210210
}
211211

212212
// branch_point is the highest tree-candidate common block.
213213
if (!get_is_strong(strong, work, branch_point))
214214
{
215-
handler(fault(error::get_is_strong), height);
215+
handler(fault(error::organize3), height);
216216
return;
217217
}
218218

@@ -235,7 +235,7 @@ void CLASS::do_organize(typename Block::cptr block,
235235
const auto top_candidate = state_->height();
236236
if (branch_point > top_candidate)
237237
{
238-
handler(fault(error::invalid_branch_point), height);
238+
handler(fault(error::organize4), height);
239239
return;
240240
}
241241

@@ -247,7 +247,7 @@ void CLASS::do_organize(typename Block::cptr block,
247247
if ((is_under_milestone(index) && !query.set_unstrong(candidate)) ||
248248
!query.pop_candidate())
249249
{
250-
handler(fault(error::pop_candidate), height);
250+
handler(fault(error::organize5), height);
251251
return;
252252
}
253253

@@ -264,7 +264,7 @@ void CLASS::do_organize(typename Block::cptr block,
264264
if ((is_under_milestone(index) && !query.set_strong(link)) ||
265265
!query.push_candidate(link))
266266
{
267-
handler(fault(error::push_candidate), height);
267+
handler(fault(error::organize6), height);
268268
return;
269269
}
270270

@@ -347,15 +347,15 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
347347
size_t height{};
348348
if (!query.get_height(height, link) || is_zero(height))
349349
{
350-
fault(error::get_height);
350+
fault(error::organize7);
351351
return;
352352
}
353353

354354
// Must reorganize down to fork point, since entire branch is now weak.
355355
const auto fork_point = query.get_fork();
356356
if (height <= fork_point)
357357
{
358-
fault(error::invalid_fork_point);
358+
fault(error::organize8);
359359
return;
360360
}
361361

@@ -365,7 +365,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
365365
auto state = query.get_candidate_chain_state(settings_, fork_point);
366366
if (!state)
367367
{
368-
fault(error::get_candidate_chain_state);
368+
fault(error::organize9);
369369
return;
370370
}
371371

@@ -378,7 +378,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
378378
{
379379
if (!get_block(block, index))
380380
{
381-
fault(error::get_block);
381+
fault(error::organize10);
382382
return;
383383
}
384384

@@ -398,7 +398,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
398398
if ((is_under_milestone(index) && !query.set_unstrong(candidate)) ||
399399
!query.pop_candidate())
400400
{
401-
fault(error::pop_candidate);
401+
fault(error::organize11);
402402
return;
403403
}
404404

@@ -418,7 +418,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
418418
// Confirmed are already set_strong and must stay that way.
419419
if (!query.push_candidate(query.to_confirmed(index)))
420420
{
421-
fault(error::push_candidate);
421+
fault(error::organize12);
422422
return;
423423
}
424424

@@ -428,7 +428,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
428428
state = query.get_candidate_chain_state(settings_, top_confirmed);
429429
if (!state)
430430
{
431-
fault(error::get_candidate_chain_state);
431+
fault(error::organize13);
432432
return;
433433
}
434434

@@ -552,7 +552,7 @@ code CLASS::push_block(const Block& block,
552552
return ec;
553553

554554
if (!query.push_candidate(link))
555-
return error::push_candidate;
555+
return error::organize14;
556556

557557
return ec;
558558
}
@@ -562,7 +562,7 @@ code CLASS::push_block(const system::hash_digest& key) NOEXCEPT
562562
{
563563
const auto handle = tree_.extract(key);
564564
if (!handle)
565-
return error::branch_error;
565+
return error::organize15;
566566

567567
const auto& value = handle.mapped();
568568
return push_block(*value.block, value.state->context());

0 commit comments

Comments
 (0)