Skip to content

Commit 15ad640

Browse files
authored
Merge pull request #932 from evoskuil/master
Suspend outer confirm loop while network is suspended.
2 parents 557557b + d656cf7 commit 15ad640

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

src/chasers/chaser_confirm.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ bool chaser_confirm::handle_event(const code&, chase event_,
6565
return false;
6666

6767
// Stop generating query during suspension.
68+
// Incoming events may already be flushed to the strand at this point.
6869
if (suspended())
6970
return true;
7071

@@ -132,13 +133,17 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT
132133
void chaser_confirm::do_bumped(height_t) NOEXCEPT
133134
{
134135
BC_ASSERT(stranded());
135-
const auto& query = archive();
136136

137137
if (closed())
138138
return;
139139

140+
// Stop while suspended as iteration is O(N^2) if blocks not organized.
141+
if (suspended())
142+
return;
143+
140144
// Guarded by candidate interlock.
141145
size_t fork_point{};
146+
const auto& query = archive();
142147
auto fork = query.get_validated_fork(fork_point, checkpoint(), filter_);
143148

144149
// Fork may be empty if candidates were reorganized.
@@ -221,6 +226,7 @@ void chaser_confirm::organize(header_states& fork, const header_links& popped,
221226
auto& query = archive();
222227
auto height = add1(fork_point);
223228

229+
// Continue when suspended as write error terminates synchronous loop.
224230
for (const auto& state: fork)
225231
{
226232
switch (state.ec.value())
@@ -238,6 +244,7 @@ void chaser_confirm::organize(header_states& fork, const header_links& popped,
238244
}
239245
case database::error::block_valid:
240246
{
247+
// False always sets a store fault (including for disk full).
241248
if (!confirm_block(state.link, height, popped, fork_point))
242249
return;
243250

src/chasers/chaser_snapshot.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ bool chaser_snapshot::handle_event(const code&, chase event_,
7979
return false;
8080

8181
// Stop generating query during suspension.
82+
// Incoming events may already be flushed to the strand at this point.
8283
if (suspended())
8384
return true;
8485

src/chasers/chaser_template.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ bool chaser_template::handle_event(const code&, chase event_,
5757
return false;
5858

5959
// Stop generating query during suspension.
60+
// Incoming events may already be flushed to the strand at this point.
6061
if (suspended())
6162
return true;
6263

src/chasers/chaser_transaction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ bool chaser_transaction::handle_event(const code&, chase event_,
5858

5959
// TODO: allow required messages.
6060
////// Stop generating query during suspension.
61+
////// Incoming events may already be flushed to the strand at this point.
6162
////if (suspended())
6263
//// return true;
6364

src/chasers/chaser_validate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ bool chaser_validate::handle_event(const code&, chase event_,
6767
return false;
6868

6969
// Stop generating query during suspension.
70+
// Incoming events may already be flushed to the strand at this point.
7071
if (suspended())
7172
return true;
7273

@@ -161,6 +162,7 @@ void chaser_validate::do_bumped(height_t height) NOEXCEPT
161162
const auto& query = archive();
162163

163164
// Bypass until next event if validation backlog is full.
165+
// Stop when suspended as write error des not terminate asynchronous loop.
164166
while ((backlog_ < maximum_backlog_) && !closed() && !suspended())
165167
{
166168
const auto link = query.to_candidate(height);

src/full_node.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ void full_node::fault(const code& ec) NOEXCEPT
379379
LOGF("Node fault, " << ec.message());
380380
}
381381

382+
// If a call does not get all of the channels, subsequent failures do so.
382383
suspend(ec);
383384
}
384385

0 commit comments

Comments
 (0)