Browse Source

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>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
dff50c3a5f
  1. 4
      daemon/peer.c
  2. 8
      state.h

4
daemon/peer.c

@ -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;
}

8
state.h

@ -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))

Loading…
Cancel
Save