Browse Source

gossip_store: Save local_add_channel messages and replay them

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

2
gossipd/gossip.c

@ -806,6 +806,8 @@ static struct io_plan *owner_msg_in(struct io_conn *conn,
} else if (type == WIRE_GOSSIP_GET_UPDATE) {
handle_get_update(peer, dc->msg_in);
} else if (type == WIRE_GOSSIP_LOCAL_ADD_CHANNEL) {
gossip_store_local_add_channel(peer->daemon->rstate->store,
dc->msg_in);
handle_local_add_channel(peer->daemon->rstate, dc->msg_in);
} else {
status_broken("peer %s: send us unknown msg of type %s",

12
gossipd/gossip_store.c

@ -109,6 +109,15 @@ void gossip_store_add_channel_delete(struct gossip_store *gs,
tal_free(msg);
}
void gossip_store_local_add_channel(struct gossip_store *gs,
const u8 *add_msg)
{
u8 *msg = towire_gossip_store_local_add_channel(NULL, add_msg);
gossip_store_append(gs, msg);
tal_free(msg);
}
void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
{
beint32_t belen;
@ -163,6 +172,9 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
}
tal_free(c);
stats[3]++;
} else if (fromwire_gossip_store_local_add_channel(
msg, msg, &gossip_msg)) {
handle_local_add_channel(rstate, gossip_msg);
} else {
bad = "Unknown message";
goto truncate;

4
gossipd/gossip_store.csv

@ -14,3 +14,7 @@ gossip_store_node_announcement,,announcement,len*u8
gossip_store_channel_delete,4099
gossip_store_channel_delete,,short_channel_id,struct short_channel_id
gossip_store_local_add_channel,4100
gossip_store_local_add_channel,,len,u16
gossip_store_local_add_channel,,local_add,len*u8
Can't render this file because it has a wrong number of fields in line 2.

6
gossipd/gossip_store.h

@ -30,6 +30,12 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs);
void gossip_store_add_channel_announcement(struct gossip_store *gs,
const u8 *gossip_msg, u64 satoshis);
/**
* Store a local_add_channel so we remember it when restarting
*/
void gossip_store_local_add_channel(struct gossip_store *gs,
const u8 *add_msg);
/**
* Store a channel_update with its associated data in the gossip_store
*/

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

@ -74,6 +74,9 @@ bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_c
/* 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_gossip_store_local_add_channel */
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_node_announcement */
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
@ -117,6 +120,9 @@ u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct s
/* 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(); }
/* Generated stub for towire_gossip_store_local_add_channel */
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_node_announcement */
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }

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

@ -38,6 +38,9 @@ bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_c
/* 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_gossip_store_local_add_channel */
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_node_announcement */
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
@ -81,6 +84,9 @@ u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct s
/* 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(); }
/* Generated stub for towire_gossip_store_local_add_channel */
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_node_announcement */
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }

6
gossipd/test/run-find_route.c

@ -36,6 +36,9 @@ bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_c
/* 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_gossip_store_local_add_channel */
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_node_announcement */
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
@ -79,6 +82,9 @@ u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct s
/* 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(); }
/* Generated stub for towire_gossip_store_local_add_channel */
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_node_announcement */
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }

Loading…
Cancel
Save