mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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>
This commit is contained in:
committed by
Christian Decker
parent
d499c34db2
commit
86a04c59d4
@@ -103,6 +103,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||||||
enum side funder,
|
enum side funder,
|
||||||
/* NULL or stolen */
|
/* NULL or stolen */
|
||||||
struct log *log,
|
struct log *log,
|
||||||
|
const char *transient_billboard TAKES,
|
||||||
u8 channel_flags,
|
u8 channel_flags,
|
||||||
const struct channel_config *our_config,
|
const struct channel_config *our_config,
|
||||||
u32 minimum_depth,
|
u32 minimum_depth,
|
||||||
@@ -147,6 +148,9 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||||||
channel->state = state;
|
channel->state = state;
|
||||||
channel->funder = funder;
|
channel->funder = funder;
|
||||||
channel->owner = NULL;
|
channel->owner = NULL;
|
||||||
|
memset(&channel->billboard, 0, sizeof(channel->billboard));
|
||||||
|
channel->billboard.transient = tal_strdup(channel, transient_billboard);
|
||||||
|
|
||||||
if (!log) {
|
if (!log) {
|
||||||
/* FIXME: update log prefix when we get scid */
|
/* FIXME: update log prefix when we get scid */
|
||||||
/* FIXME: Use minimal unique pubkey prefix for logs! */
|
/* 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);
|
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, ...)
|
void channel_fail_transient(struct channel *channel, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
struct uncommitted_channel;
|
struct uncommitted_channel;
|
||||||
|
|
||||||
|
struct billboard {
|
||||||
|
/* Status information to display on listpeers */
|
||||||
|
const char *permanent[CHANNEL_STATE_MAX+1];
|
||||||
|
const char *transient;
|
||||||
|
};
|
||||||
|
|
||||||
struct channel {
|
struct channel {
|
||||||
/* Inside peer->channels. */
|
/* Inside peer->channels. */
|
||||||
struct list_node list;
|
struct list_node list;
|
||||||
@@ -35,6 +41,7 @@ struct channel {
|
|||||||
|
|
||||||
/* History */
|
/* History */
|
||||||
struct log *log;
|
struct log *log;
|
||||||
|
struct billboard billboard;
|
||||||
|
|
||||||
/* Channel flags from opening message. */
|
/* Channel flags from opening message. */
|
||||||
u8 channel_flags;
|
u8 channel_flags;
|
||||||
@@ -92,6 +99,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||||||
enum side funder,
|
enum side funder,
|
||||||
/* NULL or stolen */
|
/* NULL or stolen */
|
||||||
struct log *log,
|
struct log *log,
|
||||||
|
const char *transient_billboard TAKES,
|
||||||
u8 channel_flags,
|
u8 channel_flags,
|
||||||
const struct channel_config *our_config,
|
const struct channel_config *our_config,
|
||||||
u32 minimum_depth,
|
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,
|
void derive_channel_seed(struct lightningd *ld, struct privkey *seed,
|
||||||
const struct pubkey *peer_id,
|
const struct pubkey *peer_id,
|
||||||
const u64 dbid);
|
const u64 dbid);
|
||||||
|
|
||||||
|
void channel_set_billboard(struct channel *channel, bool perm,
|
||||||
|
const char *str TAKES);
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_H */
|
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_H */
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
CHANNELD_AWAITING_LOCKIN,
|
CHANNELD_AWAITING_LOCKIN,
|
||||||
uc->fc ? LOCAL : REMOTE,
|
uc->fc ? LOCAL : REMOTE,
|
||||||
uc->log,
|
uc->log,
|
||||||
|
"Eat at Joes!",
|
||||||
channel_flags,
|
channel_flags,
|
||||||
&uc->our_config,
|
&uc->our_config,
|
||||||
uc->minimum_depth,
|
uc->minimum_depth,
|
||||||
|
|||||||
@@ -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, 5),
|
||||||
sqlite3_column_int(stmt, 6),
|
sqlite3_column_int(stmt, 6),
|
||||||
NULL, /* Set up fresh log */
|
NULL, /* Set up fresh log */
|
||||||
|
"Loaded from database",
|
||||||
sqlite3_column_int(stmt, 7),
|
sqlite3_column_int(stmt, 7),
|
||||||
&our_config,
|
&our_config,
|
||||||
sqlite3_column_int(stmt, 8),
|
sqlite3_column_int(stmt, 8),
|
||||||
|
|||||||
Reference in New Issue
Block a user