mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
gossip: Add the struct exclude_entry and enum exclude_entry_type
This commit is contained in:
committed by
ZmnSCPxj, ZmnSCPxj jxPCSmnZ
parent
90fa2ae3fd
commit
090a43fd3d
@@ -268,6 +268,19 @@ struct route_hop {
|
|||||||
u32 delay;
|
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,
|
struct routing_state *new_routing_state(const tal_t *ctx,
|
||||||
const struct chainparams *chainparams,
|
const struct chainparams *chainparams,
|
||||||
const struct node_id *local_id,
|
const struct node_id *local_id,
|
||||||
|
|||||||
@@ -195,3 +195,33 @@ void towire_peer_features(u8 **pptr, const struct peer_features *pf)
|
|||||||
towire_u16(pptr, tal_count(pf->globalfeatures));
|
towire_u16(pptr, tal_count(pf->globalfeatures));
|
||||||
towire_u8_array(pptr, pf->globalfeatures, 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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -61,4 +61,9 @@ fromwire_gossip_getchannels_entry(const tal_t *ctx,
|
|||||||
void towire_gossip_getchannels_entry(
|
void towire_gossip_getchannels_entry(
|
||||||
u8 **pptr, const struct gossip_getchannels_entry *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 */
|
#endif /* LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H */
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ class Type(FieldSet):
|
|||||||
'wirestring',
|
'wirestring',
|
||||||
'per_peer_state',
|
'per_peer_state',
|
||||||
'bitcoin_tx_output',
|
'bitcoin_tx_output',
|
||||||
|
'exclude_entry',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Some BOLT types are re-typed based on their field name
|
# Some BOLT types are re-typed based on their field name
|
||||||
|
|||||||
Reference in New Issue
Block a user