mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 15:00:34 +01:00
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>
This commit is contained in:
parent
ea74bac8b8
commit
99e48c7c87
3 changed files with 7 additions and 19 deletions
|
@ -504,9 +504,7 @@ static bool open_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||||
Pkt *err;
|
Pkt *err;
|
||||||
struct commit_info *ci;
|
struct commit_info *ci;
|
||||||
|
|
||||||
/* FIXME: Collapse these two states */
|
assert(peer->state == STATE_OPEN_WAIT_FOR_OPENPKT);
|
||||||
assert(peer->state == STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR
|
|
||||||
|| peer->state == STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR);
|
|
||||||
|
|
||||||
/* FIXME: Handle PKT_SHUTDOWN? */
|
/* FIXME: Handle PKT_SHUTDOWN? */
|
||||||
if (pkt->pkt_case != PKT__PKT_OPEN)
|
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);
|
keep_going = shutdown_pkt_in(peer, peer->inpkt);
|
||||||
else if (peer->state == STATE_MUTUAL_CLOSING)
|
else if (peer->state == STATE_MUTUAL_CLOSING)
|
||||||
keep_going = closing_pkt_in(peer, peer->inpkt);
|
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);
|
keep_going = open_pkt_in(peer, peer->inpkt);
|
||||||
else if (state_is_opening(peer->state)) {
|
else if (state_is_opening(peer->state)) {
|
||||||
if (peer->local.offer_anchor)
|
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);
|
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! */
|
/* FIXME: Start timeout, and close peer if they don't progress! */
|
||||||
if (peer->local.offer_anchor) {
|
if (peer->local.offer_anchor)
|
||||||
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR,
|
|
||||||
__func__, false);
|
|
||||||
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
|
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
|
||||||
} else {
|
else
|
||||||
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR,
|
|
||||||
__func__, false);
|
|
||||||
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR;
|
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR;
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: Delay db write until we have something to keep, or handle
|
/* FIXME: Delay db write until we have something to keep, or handle
|
||||||
* reconnect with STATE_INIT state. */
|
* reconnect with STATE_INIT state. */
|
||||||
|
|
6
state.h
6
state.h
|
@ -40,12 +40,6 @@ static inline bool state_is_opening(enum state s)
|
||||||
return s < STATE_NORMAL;
|
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)
|
static inline bool state_is_waiting_for_anchor(enum state s)
|
||||||
{
|
{
|
||||||
return s == STATE_OPEN_WAITING_OURANCHOR
|
return s == STATE_OPEN_WAITING_OURANCHOR
|
||||||
|
|
|
@ -10,8 +10,7 @@ enum state {
|
||||||
/*
|
/*
|
||||||
* Opening.
|
* Opening.
|
||||||
*/
|
*/
|
||||||
STATE_OPEN_WAIT_FOR_OPEN_NOANCHOR,
|
STATE_OPEN_WAIT_FOR_OPENPKT,
|
||||||
STATE_OPEN_WAIT_FOR_OPEN_WITHANCHOR,
|
|
||||||
STATE_OPEN_WAIT_FOR_ANCHOR,
|
STATE_OPEN_WAIT_FOR_ANCHOR,
|
||||||
STATE_OPEN_WAIT_FOR_COMMIT_SIG,
|
STATE_OPEN_WAIT_FOR_COMMIT_SIG,
|
||||||
STATE_OPEN_WAITING_OURANCHOR,
|
STATE_OPEN_WAITING_OURANCHOR,
|
||||||
|
|
Loading…
Add table
Reference in a new issue