Browse Source

gossip: Pull up the check for new channels before checking the txout

We drop all but the first announcement, so any work that is done for a
channel that we already know is wasted. Pulling this up duplicates
some of the work but allows us to skip the costly txout check.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
7a651c62fa
  1. 11
      gossipd/routing.c

11
gossipd/routing.c

@ -545,6 +545,7 @@ const struct short_channel_id *handle_channel_announcement(
const char *tag;
secp256k1_ecdsa_signature node_signature_1, node_signature_2;
secp256k1_ecdsa_signature bitcoin_signature_1, bitcoin_signature_2;
struct node_connection *c0, *c1;
pending = tal(rstate, struct pending_cannouncement);
pending->updates[0] = NULL;
@ -619,10 +620,16 @@ const struct short_channel_id *handle_channel_announcement(
/* FIXME: Handle duplicates as per BOLT #7 */
if (find_pending_cannouncement(rstate, &pending->short_channel_id) != NULL) {
/* Drop it like it's hot */
c0 = get_connection(rstate, &pending->node_id_2, &pending->node_id_1);
c1 = get_connection(rstate, &pending->node_id_1, &pending->node_id_2);
/* If we know the channels, or we have already a pending check, then skip */
if ((c0 != NULL && c1 != NULL) ||
find_pending_cannouncement(rstate, &pending->short_channel_id) !=
NULL) {
return tal_free(pending);
}
list_add_tail(&rstate->pending_cannouncement, &pending->list);
return &pending->short_channel_id;
}

Loading…
Cancel
Save