peer: do not send anchor depth input twice.

We *should* be in a state which accepts it (could happen with reorg),
and there's no reason to test for greater than depth since we must process
blocks in order.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-09-13 15:23:37 +09:30
parent 7b5806fef2
commit dff50c3a5f
2 changed files with 10 additions and 2 deletions

View File

@ -2960,8 +2960,8 @@ static enum watch_result anchor_depthchange(struct peer *peer,
void *unused)
{
/* Still waiting for it to reach depth? */
if (state_is_opening(peer->state)) {
if ((int)depth >= peer->anchor.ok_depth) {
if (state_is_waiting_for_anchor(peer->state)) {
if ((int)depth == peer->anchor.ok_depth) {
state_event(peer, BITCOIN_ANCHOR_DEPTHOK, NULL);
peer->anchor.ok_depth = -1;
}

View File

@ -40,6 +40,14 @@ static inline bool state_is_opening(enum state s)
return s < STATE_NORMAL;
}
static inline bool state_is_waiting_for_anchor(enum state s)
{
return s == STATE_OPEN_WAITING_OURANCHOR
|| s == STATE_OPEN_WAITING_OURANCHOR_THEYCOMPLETED
|| s == STATE_OPEN_WAITING_THEIRANCHOR
|| s == STATE_OPEN_WAITING_THEIRANCHOR_THEYCOMPLETED;
}
static inline bool state_can_io(enum state s)
{
if (state_is_error(s))