Browse Source

lightningd: maintain a status billboard for each channel.

Each state (effectively, each daemon) has two slots: a permanent slot
if something permanent happens (usually, a failure), and a transient
slot which summarizes what's happening right now.

Uncommitted channels only have a transient slot, by their very nature.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
86a04c59d4
  1. 19
      lightningd/channel.c
  2. 11
      lightningd/channel.h
  3. 1
      lightningd/opening_control.c
  4. 1
      wallet/wallet.c

19
lightningd/channel.c

@ -103,6 +103,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
enum side funder,
/* NULL or stolen */
struct log *log,
const char *transient_billboard TAKES,
u8 channel_flags,
const struct channel_config *our_config,
u32 minimum_depth,
@ -147,6 +148,9 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
channel->state = state;
channel->funder = funder;
channel->owner = NULL;
memset(&channel->billboard, 0, sizeof(channel->billboard));
channel->billboard.transient = tal_strdup(channel, transient_billboard);
if (!log) {
/* FIXME: update log prefix when we get scid */
/* FIXME: Use minimal unique pubkey prefix for logs! */
@ -314,6 +318,21 @@ void channel_internal_error(struct channel *channel, const char *fmt, ...)
tal_free(why);
}
void channel_set_billboard(struct channel *channel, bool perm, const char *str)
{
const char **p;
if (perm)
p = &channel->billboard.permanent[channel->state];
else
p = &channel->billboard.transient;
tal_free(*p);
*p = tal_fmt(channel, "%s:%s", channel_state_name(channel), str);
if (taken(str))
tal_free(str);
}
void channel_fail_transient(struct channel *channel, const char *fmt, ...)
{
va_list ap;

11
lightningd/channel.h

@ -8,6 +8,12 @@
struct uncommitted_channel;
struct billboard {
/* Status information to display on listpeers */
const char *permanent[CHANNEL_STATE_MAX+1];
const char *transient;
};
struct channel {
/* Inside peer->channels. */
struct list_node list;
@ -35,6 +41,7 @@ struct channel {
/* History */
struct log *log;
struct billboard billboard;
/* Channel flags from opening message. */
u8 channel_flags;
@ -92,6 +99,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
enum side funder,
/* NULL or stolen */
struct log *log,
const char *transient_billboard TAKES,
u8 channel_flags,
const struct channel_config *our_config,
u32 minimum_depth,
@ -199,4 +207,7 @@ static inline bool channel_wants_reconnect(const struct channel *channel)
void derive_channel_seed(struct lightningd *ld, struct privkey *seed,
const struct pubkey *peer_id,
const u64 dbid);
void channel_set_billboard(struct channel *channel, bool perm,
const char *str TAKES);
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_H */

1
lightningd/opening_control.c

@ -173,6 +173,7 @@ wallet_commit_channel(struct lightningd *ld,
CHANNELD_AWAITING_LOCKIN,
uc->fc ? LOCAL : REMOTE,
uc->log,
"Eat at Joes!",
channel_flags,
&uc->our_config,
uc->minimum_depth,

1
wallet/wallet.c

@ -573,6 +573,7 @@ static struct channel *wallet_stmt2channel(const tal_t *ctx, struct wallet *w, s
sqlite3_column_int(stmt, 5),
sqlite3_column_int(stmt, 6),
NULL, /* Set up fresh log */
"Loaded from database",
sqlite3_column_int(stmt, 7),
&our_config,
sqlite3_column_int(stmt, 8),

Loading…
Cancel
Save