diff --git a/gossipd/gossip.c b/gossipd/gossip.c index c80c5ad5f..47aa96e12 100644 --- a/gossipd/gossip.c +++ b/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", diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index 2622d362f..5fb94f924 100644 --- a/gossipd/gossip_store.c +++ b/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; diff --git a/gossipd/gossip_store.csv b/gossipd/gossip_store.csv index eaf34fa7a..f10fb09a6 100644 --- a/gossipd/gossip_store.csv +++ b/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 \ No newline at end of file diff --git a/gossipd/gossip_store.h b/gossipd/gossip_store.h index d5e80925c..c552b5590 100644 --- a/gossipd/gossip_store.h +++ b/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 */ diff --git a/gossipd/test/run-bench-find_route.c b/gossipd/test/run-bench-find_route.c index 392a396ee..b35ca9f4b 100644 --- a/gossipd/test/run-bench-find_route.c +++ b/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(); } diff --git a/gossipd/test/run-find_route-specific.c b/gossipd/test/run-find_route-specific.c index 8b825036b..0a7ff0dce 100644 --- a/gossipd/test/run-find_route-specific.c +++ b/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(); } diff --git a/gossipd/test/run-find_route.c b/gossipd/test/run-find_route.c index 26eb5a896..6667250f6 100644 --- a/gossipd/test/run-find_route.c +++ b/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(); }