Browse Source

lightningd: Store commands that try to forget channel in `struct channel`

travis-debug
trueptolemy 5 years ago
committed by neil saitug
parent
commit
1e5b619832
  1. 7
      lightningd/channel.c
  2. 3
      lightningd/channel.h

7
lightningd/channel.c

@ -1,6 +1,8 @@
#include <bitcoin/script.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
#include <common/jsonrpc_errors.h>
#include <common/wire_error.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
@ -97,6 +99,10 @@ static void destroy_channel(struct channel *channel)
channel_state_name(channel),
htlc_state_name(hin->hstate));
for (size_t i = 0; i < tal_count(channel->forgets); i++)
was_pending(command_fail(channel->forgets[i], LIGHTNINGD,
"Channel structure was freed!"));
/* Free any old owner still hanging around. */
channel_set_owner(channel, NULL);
@ -250,6 +256,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
channel->remote_upfront_shutdown_script
= tal_steal(channel, remote_upfront_shutdown_script);
channel->option_static_remotekey = option_static_remotekey;
channel->forgets = tal_arr(channel, struct command *, 0);
list_add_tail(&peer->channels, &channel->list);
tal_add_destructor(channel, destroy_channel);

3
lightningd/channel.h

@ -120,6 +120,9 @@ struct channel {
/* Was this negotiated with `option_static_remotekey? */
bool option_static_remotekey;
/* Any commands trying to forget us. */
struct command **forgets;
};
struct channel *new_channel(struct peer *peer, u64 dbid,

Loading…
Cancel
Save