Browse Source

peer: don't differentiate who is funding via state when waiting for open.

It doesn't actually help here; we only did it because we differentiate
the states later, and with refactoring we do that via the explicit
offer_anchor flag.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
99e48c7c87
  1. 17
      daemon/peer.c
  2. 6
      state.h
  3. 3
      state_types.h

17
daemon/peer.c

@ -504,9 +504,7 @@ static bool open_pkt_in(struct peer *peer, const Pkt *pkt)
Pkt *err;
struct commit_info *ci;
/* FIXME: Collapse these two states */
assert(peer->state == STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR
|| peer->state == STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR);
assert(peer->state == STATE_OPEN_WAIT_FOR_OPENPKT);
/* FIXME: Handle PKT_SHUTDOWN? */
if (pkt->pkt_case != PKT__PKT_OPEN)
@ -2229,7 +2227,7 @@ static struct io_plan *pkt_in(struct io_conn *conn, struct peer *peer)
keep_going = shutdown_pkt_in(peer, peer->inpkt);
else if (peer->state == STATE_MUTUAL_CLOSING)
keep_going = closing_pkt_in(peer, peer->inpkt);
else if (state_is_waiting_for_open(peer->state))
else if (peer->state == STATE_OPEN_WAIT_FOR_OPENPKT)
keep_going = open_pkt_in(peer, peer->inpkt);
else if (state_is_opening(peer->state)) {
if (peer->local.offer_anchor)
@ -2599,16 +2597,13 @@ static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
assert(peer->state == STATE_INIT);
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPENPKT, __func__, false);
/* FIXME: Start timeout, and close peer if they don't progress! */
if (peer->local.offer_anchor) {
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR,
__func__, false);
if (peer->local.offer_anchor)
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
} else {
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR,
__func__, false);
else
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR;
}
/* FIXME: Delay db write until we have something to keep, or handle
* reconnect with STATE_INIT state. */

6
state.h

@ -40,12 +40,6 @@ static inline bool state_is_opening(enum state s)
return s < STATE_NORMAL;
}
static inline bool state_is_waiting_for_open(enum state s)
{
return s == STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR
|| s == STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR;
}
static inline bool state_is_waiting_for_anchor(enum state s)
{
return s == STATE_OPEN_WAITING_OURANCHOR

3
state_types.h

@ -10,8 +10,7 @@ enum state {
/*
* Opening.
*/
STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR,
STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR,
STATE_OPEN_WAIT_FOR_OPENPKT,
STATE_OPEN_WAIT_FOR_ANCHOR,
STATE_OPEN_WAIT_FOR_COMMIT_SIG,
STATE_OPEN_WAITING_OURANCHOR,

Loading…
Cancel
Save