gossip: Pass broadcast_state to gossip_store

We'll be sourcing messages from this `broadcast_state` when rewriting the
`gossip_store`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-05-30 14:27:32 +02:00
parent 37dc458b4d
commit 552ddb8dfd
3 changed files with 10 additions and 3 deletions

View File

@ -18,6 +18,10 @@ static u8 gossip_store_version = 0x02;
struct gossip_store {
int fd;
u8 version;
/* The broadcast struct we source messages from when rewriting the
* gossip_store */
struct broadcast_state *broadcast;
};
static void gossip_store_destroy(struct gossip_store *gs)
@ -25,10 +29,12 @@ static void gossip_store_destroy(struct gossip_store *gs)
close(gs->fd);
}
struct gossip_store *gossip_store_new(const tal_t *ctx)
struct gossip_store *gossip_store_new(const tal_t *ctx,
struct broadcast_state *broadcast)
{
struct gossip_store *gs = tal(ctx, struct gossip_store);
gs->fd = open(GOSSIP_STORE_FILENAME, O_RDWR|O_APPEND|O_CREAT, 0600);
gs->broadcast = broadcast;
tal_add_destructor(gs, gossip_store_destroy);

View File

@ -14,7 +14,8 @@
struct gossip_store;
struct routing_state;
struct gossip_store *gossip_store_new(const tal_t *ctx);
struct gossip_store *gossip_store_new(const tal_t *ctx,
struct broadcast_state *broadcast);
/**
* Load the initial gossip store, if any.

View File

@ -96,7 +96,7 @@ struct routing_state *new_routing_state(const tal_t *ctx,
rstate->chain_hash = *chain_hash;
rstate->local_id = *local_id;
rstate->prune_timeout = prune_timeout;
rstate->store = gossip_store_new(rstate);
rstate->store = gossip_store_new(rstate, rstate->broadcasts);
rstate->dev_allow_localhost = dev_allow_localhost;
rstate->local_channel_announced = false;
list_head_init(&rstate->pending_cannouncement);