Browse Source

gossip: Wrap channel_updates in the gossip_store as well

Bypasses verification when loading from the gossip_store.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
db13c7e851
  1. 12
      gossipd/gossip_store.c
  2. 7
      gossipd/gossip_store.h
  3. 5
      gossipd/routing.c
  4. 6
      gossipd/test/run-bench-find_route.c
  5. 6
      gossipd/test/run-find_route-specific.c
  6. 6
      gossipd/test/run-find_route.c

12
gossipd/gossip_store.c

@ -66,6 +66,14 @@ void gossip_store_add_channel_announcement(struct gossip_store *gs, const u8 *go
tal_free(msg);
}
void gossip_store_add_channel_update(struct gossip_store *gs,
const u8 *gossip_msg)
{
u8 *msg = towire_gossip_store_channel_update(NULL, gossip_msg);
gossip_store_append(gs, msg);
tal_free(msg);
}
const u8 *gossip_store_read_next(const tal_t *ctx, struct routing_state *rstate,
struct gossip_store *gs)
{
@ -109,6 +117,10 @@ const u8 *gossip_store_read_next(const tal_t *ctx, struct routing_state *rstate,
/* No harm in returning it, it'll get discarded as a duplicate */
return gossip_msg;
} else if(type == WIRE_GOSSIP_STORE_CHANNEL_UPDATE) {
fromwire_gossip_store_channel_update(msg, msg, &gossip_msg);
routing_add_channel_update(rstate, gossip_msg);
return gossip_msg;
}
return msg;

7
gossipd/gossip_store.h

@ -40,4 +40,11 @@ const u8 *gossip_store_read_next(const tal_t *ctx, struct routing_state *rstate,
*/
void gossip_store_add_channel_announcement(struct gossip_store *gs,
const u8 *gossip_msg, u64 satoshis);
/**
* Store a channel_update with its associated data in the gossip_store
*/
void gossip_store_add_channel_update(struct gossip_store *gs,
const u8 *gossip_msg);
#endif /* GOSSIPD_GOSSIP_STORE_H */

5
gossipd/routing.c

@ -1029,8 +1029,9 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update,
flags & 0x01,
flags & ROUTING_FLAGS_DISABLED ? "DISABLED" : "ACTIVE");
if (store)
gossip_store_append(rstate->store, serialized);
/* Only store updates for public channels */
if (chan->public)
gossip_store_add_channel_update(rstate->store, serialized);
routing_add_channel_update(rstate, serialized);
return NULL;
}

6
gossipd/test/run-bench-find_route.c

@ -65,6 +65,9 @@ bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_update */
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
@ -102,6 +105,9 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
/* Generated stub for towire_gossip_store_channel_announcement */
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, u64 satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_update */
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
/* Updates existing route if required. */

6
gossipd/test/run-find_route-specific.c

@ -29,6 +29,9 @@ bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_update */
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
@ -66,6 +69,9 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
/* Generated stub for towire_gossip_store_channel_announcement */
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, u64 satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_update */
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
const void *trc;

6
gossipd/test/run-find_route.c

@ -27,6 +27,9 @@ bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_update */
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
@ -64,6 +67,9 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
/* Generated stub for towire_gossip_store_channel_announcement */
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, u64 satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_update */
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
/* Updates existing route if required. */

Loading…
Cancel
Save