mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +01:00
72108f0cb9
We derive the seed from this, so it needs to be unique, but using rowid forced us to put the channel into the db early, before it was ready. Instead, use a counter to ensure uniqueness, initialized when we load existing peers. This doesn't need to touch the database at all. As we now have only two places where the channel is committed (the funder and fundee paths), so we create a new explicit 'wallet_channel_insert()' function: 'wallet_channel_save()' now just updates. Note that this also fixes some weirdness in wallet_channels_load_active: we strangely avoided loading channels in CLOSINGD_COMPLETE (which fortunately was a transient state, so unlikely anyone hit this). Note that since the lines above already delete all the OPENINGD channels, we now simply load them all. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
39 lines
863 B
C
39 lines
863 B
C
#ifndef LIGHTNING_LIGHTNINGD_PEER_STATE_H
|
|
#define LIGHTNING_LIGHTNINGD_PEER_STATE_H
|
|
#include "config.h"
|
|
|
|
/* FIXME: rename channel_state! */
|
|
enum peer_state {
|
|
UNINITIALIZED,
|
|
|
|
/* Negotiating channel opening: in opening daemon */
|
|
OPENINGD,
|
|
|
|
/* In channeld, still waiting for lockin. */
|
|
CHANNELD_AWAITING_LOCKIN,
|
|
|
|
/* Normal operating state. */
|
|
CHANNELD_NORMAL,
|
|
|
|
/* We are closing, pending HTLC resolution. */
|
|
CHANNELD_SHUTTING_DOWN,
|
|
|
|
/* Exchanging signatures on closing tx. */
|
|
CLOSINGD_SIGEXCHANGE,
|
|
|
|
/* Waiting for onchain event. */
|
|
CLOSINGD_COMPLETE,
|
|
|
|
/* We've seen the funding spent, we're waiting for onchaind. */
|
|
FUNDING_SPEND_SEEN,
|
|
|
|
/* Various onchain states. */
|
|
ONCHAIND_CHEATED,
|
|
ONCHAIND_THEIR_UNILATERAL,
|
|
ONCHAIND_OUR_UNILATERAL,
|
|
ONCHAIND_MUTUAL
|
|
};
|
|
#define CHANNEL_STATE_MAX ONCHAIND_MUTUAL
|
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_STATE_H */
|