Skip to content

Commit

Permalink
fix: suppress duplicated channel_state_changed events
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmoock authored and rustyrussell committed Sep 10, 2020
1 parent ddc759c commit 160c564
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
16 changes: 9 additions & 7 deletions lightningd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,15 @@ void channel_set_state(struct channel *channel,
wallet_channel_save(channel->peer->ld->wallet, channel);

/* plugin notification channel_state_changed */
derive_channel_id(&cid, &channel->funding_txid, channel->funding_outnum);
notify_channel_state_changed(channel->peer->ld,
&channel->peer->id,
&cid,
channel->scid,
old_state,
state);
if (state != old_state) { /* see issue #4029 */
derive_channel_id(&cid, &channel->funding_txid, channel->funding_outnum);
notify_channel_state_changed(channel->peer->ld,
&channel->peer->id,
&cid,
channel->scid,
old_state,
state);
}
}

void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
Expand Down
8 changes: 0 additions & 8 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,14 +731,6 @@ def test_channel_state_changed_unilateral(node_factory, bitcoind):

bitcoind.generate_block(100) # so it gets settled

msg = l2.daemon.wait_for_log("channel_state_changed.*new_state.*")
event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0])
assert(event['peer_id'] == peer_id)
assert(event['channel_id'] == cid)
assert(event['short_channel_id'] == scid)
assert(event['old_state'] == "AWAITING_UNILATERAL") # this actually happens
assert(event['new_state'] == "AWAITING_UNILATERAL") # note: same states

msg = l2.daemon.wait_for_log("channel_state_changed.*new_state.*")
event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0])
assert(event['peer_id'] == peer_id)
Expand Down

0 comments on commit 160c564

Please sign in to comment.