diff --git a/gossipd/routing.h b/gossipd/routing.h index 29d6a888d..a2555f34b 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -268,6 +268,19 @@ struct route_hop { u32 delay; }; +enum exclude_entry_type { + EXCLUDE_CHANNEL = 1, + EXCLUDE_NODE = 2 +}; + +struct exclude_entry { + enum exclude_entry_type type; + union { + struct short_channel_id_dir chan_id; + struct node_id node_id; + } u; +}; + struct routing_state *new_routing_state(const tal_t *ctx, const struct chainparams *chainparams, const struct node_id *local_id, diff --git a/lightningd/gossip_msg.c b/lightningd/gossip_msg.c index afd065416..363358dbb 100644 --- a/lightningd/gossip_msg.c +++ b/lightningd/gossip_msg.c @@ -195,3 +195,33 @@ void towire_peer_features(u8 **pptr, const struct peer_features *pf) towire_u16(pptr, tal_count(pf->globalfeatures)); towire_u8_array(pptr, pf->globalfeatures, tal_count(pf->globalfeatures)); } + +struct exclude_entry *fromwire_exclude_entry(const tal_t *ctx, + const u8 **pptr, size_t *max) +{ + struct exclude_entry *entry = tal(ctx, struct exclude_entry); + entry->type = fromwire_u8(pptr, max); + switch (entry->type) { + case EXCLUDE_CHANNEL: + fromwire_short_channel_id_dir(pptr, max, &entry->u.chan_id); + return entry; + case EXCLUDE_NODE: + fromwire_node_id(pptr, max, &entry->u.node_id); + return entry; + default: + fromwire_fail(pptr, max); + return NULL; + } +} + +void towire_exclude_entry(u8 **pptr, const struct exclude_entry *entry) +{ + assert(entry->type == EXCLUDE_CHANNEL || + entry->type == EXCLUDE_NODE); + + towire_u8(pptr, entry->type); + if (entry->type == EXCLUDE_CHANNEL) + towire_short_channel_id_dir(pptr, &entry->u.chan_id); + else + towire_node_id(pptr, &entry->u.node_id); +} diff --git a/lightningd/gossip_msg.h b/lightningd/gossip_msg.h index de6b38782..a7f226766 100644 --- a/lightningd/gossip_msg.h +++ b/lightningd/gossip_msg.h @@ -61,4 +61,9 @@ fromwire_gossip_getchannels_entry(const tal_t *ctx, void towire_gossip_getchannels_entry( u8 **pptr, const struct gossip_getchannels_entry *entry); +struct exclude_entry * +fromwire_exclude_entry(const tal_t *ctx, + const u8 **pptr, size_t *max); +void towire_exclude_entry(u8 **pptr, const struct exclude_entry *entry); + #endif /* LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H */ diff --git a/tools/generate-wire.py b/tools/generate-wire.py index b1856b95a..1a3488770 100755 --- a/tools/generate-wire.py +++ b/tools/generate-wire.py @@ -217,6 +217,7 @@ class Type(FieldSet): 'wirestring', 'per_peer_state', 'bitcoin_tx_output', + 'exclude_entry', ] # Some BOLT types are re-typed based on their field name