Browse Source

short_channel_id: remove short_channel_id_to_uint accessor.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
ca4603455b
  1. 6
      bitcoin/short_channel_id.h
  2. 2
      gossipd/gossip.c
  3. 10
      gossipd/routing.c
  4. 2
      gossipd/routing.h

6
bitcoin/short_channel_id.h

@ -36,12 +36,6 @@ void mk_short_channel_id(struct short_channel_id *scid,
bool short_channel_id_from_str(const char *str, size_t strlen, bool short_channel_id_from_str(const char *str, size_t strlen,
struct short_channel_id *dst); struct short_channel_id *dst);
/* Fast, platform dependent, way to convert from a short_channel_id to u64 */
static inline u64 short_channel_id_to_uint(const struct short_channel_id *scid)
{
return scid->u64;
}
char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid); char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid);
#endif /* LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H */ #endif /* LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H */

2
gossipd/gossip.c

@ -785,7 +785,7 @@ static void handle_local_add_channel(struct peer *peer, u8 *msg)
chan = routing_channel_new(rstate, &scid); chan = routing_channel_new(rstate, &scid);
chan->public = false; chan->public = false;
uintmap_add(&rstate->channels, short_channel_id_to_uint(&scid), chan); uintmap_add(&rstate->channels, scid.u64, chan);
chan->pending = NULL; chan->pending = NULL;
direction = get_channel_direction(&rstate->local_id, &remote_node_id); direction = get_channel_direction(&rstate->local_id, &remote_node_id);

10
gossipd/routing.c

@ -338,8 +338,9 @@ static void bfg_one_edge(struct node *node, size_t edgenum, double riskfactor,
double fee_scale = 1.0; double fee_scale = 1.0;
if (fuzz != 0.0) { if (fuzz != 0.0) {
u64 scid = short_channel_id_to_uint(&c->short_channel_id); u64 h = siphash24(base_seed,
u64 h = siphash24(base_seed, &scid, sizeof(scid)); &c->short_channel_id,
sizeof(c->short_channel_id));
/* Scale fees for this channel */ /* Scale fees for this channel */
/* rand = (h / UINT64_MAX) random number between 0.0 -> 1.0 /* rand = (h / UINT64_MAX) random number between 0.0 -> 1.0
@ -651,7 +652,6 @@ const struct short_channel_id *handle_channel_announcement(
u8 *features; u8 *features;
secp256k1_ecdsa_signature node_signature_1, node_signature_2; secp256k1_ecdsa_signature node_signature_1, node_signature_2;
secp256k1_ecdsa_signature bitcoin_signature_1, bitcoin_signature_2; secp256k1_ecdsa_signature bitcoin_signature_1, bitcoin_signature_2;
u64 scid;
struct routing_channel *chan; struct routing_channel *chan;
pending = tal(rstate, struct pending_cannouncement); pending = tal(rstate, struct pending_cannouncement);
@ -677,8 +677,6 @@ const struct short_channel_id *handle_channel_announcement(
return NULL; return NULL;
} }
scid = short_channel_id_to_uint(&pending->short_channel_id);
/* Check if we know the channel already (no matter in what /* Check if we know the channel already (no matter in what
* state, we stop here if yes). */ * state, we stop here if yes). */
chan = get_channel(rstate, &pending->short_channel_id); chan = get_channel(rstate, &pending->short_channel_id);
@ -743,7 +741,7 @@ const struct short_channel_id *handle_channel_announcement(
/* The channel will be public if we complete the verification */ /* The channel will be public if we complete the verification */
chan->public = true; chan->public = true;
uintmap_add(&rstate->channels, scid, chan); uintmap_add(&rstate->channels, pending->short_channel_id.u64, chan);
/* Add both endpoints to the pending_node_map so we can stash /* Add both endpoints to the pending_node_map so we can stash
* node_announcements while we wait for the txout check */ * node_announcements while we wait for the txout check */

2
gossipd/routing.h

@ -128,7 +128,7 @@ static inline struct routing_channel *
get_channel(const struct routing_state *rstate, get_channel(const struct routing_state *rstate,
const struct short_channel_id *scid) const struct short_channel_id *scid)
{ {
return uintmap_get(&rstate->channels, short_channel_id_to_uint(scid)); return uintmap_get(&rstate->channels, scid->u64);
} }
struct route_hop { struct route_hop {

Loading…
Cancel
Save