mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
gossip_store: remove now-redundant push bit
The push bit was convenient for connectd to send our own gossip to peers upon connecting by naively traversing the gossip_store and sending anything flagged `push`. This function is now performed by gossipd leaving no use for the push bit. Changelog-Changed: `gossipd`: gossip_store PUSH bit is no longer set.
This commit is contained in:
parent
bec8586dce
commit
54bd024910
6 changed files with 15 additions and 29 deletions
|
@ -121,7 +121,7 @@ u8 *gossip_store_next(const tal_t *ctx,
|
||||||
struct gossip_hdr hdr;
|
struct gossip_hdr hdr;
|
||||||
u16 msglen, flags;
|
u16 msglen, flags;
|
||||||
u32 checksum, timestamp;
|
u32 checksum, timestamp;
|
||||||
bool push, ratelimited;
|
bool ratelimited;
|
||||||
int type, r;
|
int type, r;
|
||||||
|
|
||||||
r = pread(*gossip_store_fd, &hdr, sizeof(hdr), *off);
|
r = pread(*gossip_store_fd, &hdr, sizeof(hdr), *off);
|
||||||
|
@ -130,7 +130,6 @@ u8 *gossip_store_next(const tal_t *ctx,
|
||||||
|
|
||||||
msglen = be16_to_cpu(hdr.len);
|
msglen = be16_to_cpu(hdr.len);
|
||||||
flags = be16_to_cpu(hdr.flags);
|
flags = be16_to_cpu(hdr.flags);
|
||||||
push = (flags & GOSSIP_STORE_PUSH_BIT);
|
|
||||||
ratelimited = (flags & GOSSIP_STORE_RATELIMIT_BIT);
|
ratelimited = (flags & GOSSIP_STORE_RATELIMIT_BIT);
|
||||||
|
|
||||||
/* Skip any deleted entries. */
|
/* Skip any deleted entries. */
|
||||||
|
@ -141,8 +140,7 @@ u8 *gossip_store_next(const tal_t *ctx,
|
||||||
|
|
||||||
/* Skip any timestamp filtered */
|
/* Skip any timestamp filtered */
|
||||||
timestamp = be32_to_cpu(hdr.timestamp);
|
timestamp = be32_to_cpu(hdr.timestamp);
|
||||||
if (!push &&
|
if (!timestamp_filter(timestamp_min, timestamp_max,
|
||||||
!timestamp_filter(timestamp_min, timestamp_max,
|
|
||||||
timestamp)) {
|
timestamp)) {
|
||||||
*off += r + msglen;
|
*off += r + msglen;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -73,7 +73,7 @@ static ssize_t gossip_pwritev(int fd, const struct iovec *iov, int iovcnt,
|
||||||
#endif /* !HAVE_PWRITEV */
|
#endif /* !HAVE_PWRITEV */
|
||||||
|
|
||||||
static bool append_msg(int fd, const u8 *msg, u32 timestamp,
|
static bool append_msg(int fd, const u8 *msg, u32 timestamp,
|
||||||
bool push, bool zombie, bool spam, u64 *len)
|
bool zombie, bool spam, u64 *len)
|
||||||
{
|
{
|
||||||
struct gossip_hdr hdr;
|
struct gossip_hdr hdr;
|
||||||
u32 msglen;
|
u32 msglen;
|
||||||
|
@ -85,8 +85,6 @@ static bool append_msg(int fd, const u8 *msg, u32 timestamp,
|
||||||
msglen = tal_count(msg);
|
msglen = tal_count(msg);
|
||||||
hdr.len = cpu_to_be16(msglen);
|
hdr.len = cpu_to_be16(msglen);
|
||||||
hdr.flags = 0;
|
hdr.flags = 0;
|
||||||
if (push)
|
|
||||||
hdr.flags |= CPU_TO_BE16(GOSSIP_STORE_PUSH_BIT);
|
|
||||||
if (spam)
|
if (spam)
|
||||||
hdr.flags |= CPU_TO_BE16(GOSSIP_STORE_RATELIMIT_BIT);
|
hdr.flags |= CPU_TO_BE16(GOSSIP_STORE_RATELIMIT_BIT);
|
||||||
if (zombie)
|
if (zombie)
|
||||||
|
@ -251,7 +249,7 @@ static u32 gossip_store_compact_offline(struct routing_state *rstate)
|
||||||
oldlen = lseek(old_fd, SEEK_END, 0);
|
oldlen = lseek(old_fd, SEEK_END, 0);
|
||||||
newlen = lseek(new_fd, SEEK_END, 0);
|
newlen = lseek(new_fd, SEEK_END, 0);
|
||||||
append_msg(old_fd, towire_gossip_store_ended(tmpctx, newlen),
|
append_msg(old_fd, towire_gossip_store_ended(tmpctx, newlen),
|
||||||
0, true, false, false, &oldlen);
|
0, false, false, &oldlen);
|
||||||
close(old_fd);
|
close(old_fd);
|
||||||
status_debug("gossip_store_compact_offline: %zu deleted, %zu copied",
|
status_debug("gossip_store_compact_offline: %zu deleted, %zu copied",
|
||||||
deleted, count);
|
deleted, count);
|
||||||
|
@ -533,7 +531,7 @@ bool gossip_store_compact(struct gossip_store *gs)
|
||||||
|
|
||||||
/* Write end marker now new one is ready */
|
/* Write end marker now new one is ready */
|
||||||
append_msg(gs->fd, towire_gossip_store_ended(tmpctx, len),
|
append_msg(gs->fd, towire_gossip_store_ended(tmpctx, len),
|
||||||
0, true, false, false, &gs->len);
|
0, false, false, &gs->len);
|
||||||
|
|
||||||
gs->count = count;
|
gs->count = count;
|
||||||
gs->deleted = 0;
|
gs->deleted = 0;
|
||||||
|
@ -553,7 +551,7 @@ disable:
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
||||||
u32 timestamp, bool push, bool zombie,
|
u32 timestamp, bool zombie,
|
||||||
bool spam, const u8 *addendum)
|
bool spam, const u8 *addendum)
|
||||||
{
|
{
|
||||||
u64 off = gs->len;
|
u64 off = gs->len;
|
||||||
|
@ -561,12 +559,12 @@ u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
||||||
/* Should never get here during loading! */
|
/* Should never get here during loading! */
|
||||||
assert(gs->writable);
|
assert(gs->writable);
|
||||||
|
|
||||||
if (!append_msg(gs->fd, gossip_msg, timestamp, push, zombie, spam, &gs->len)) {
|
if (!append_msg(gs->fd, gossip_msg, timestamp, zombie, spam, &gs->len)) {
|
||||||
status_broken("Failed writing to gossip store: %s",
|
status_broken("Failed writing to gossip store: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (addendum && !append_msg(gs->fd, addendum, 0, false, false, false, &gs->len)) {
|
if (addendum && !append_msg(gs->fd, addendum, 0, false, false, &gs->len)) {
|
||||||
status_broken("Failed writing addendum to gossip store: %s",
|
status_broken("Failed writing addendum to gossip store: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -583,7 +581,7 @@ u64 gossip_store_add_private_update(struct gossip_store *gs, const u8 *update)
|
||||||
/* A local update for an unannounced channel: not broadcastable, but
|
/* A local update for an unannounced channel: not broadcastable, but
|
||||||
* otherwise the same as a normal channel_update */
|
* otherwise the same as a normal channel_update */
|
||||||
const u8 *pupdate = towire_gossip_store_private_update(tmpctx, update);
|
const u8 *pupdate = towire_gossip_store_private_update(tmpctx, update);
|
||||||
return gossip_store_add(gs, pupdate, 0, false, false, false, NULL);
|
return gossip_store_add(gs, pupdate, 0, false, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns index of following entry. */
|
/* Returns index of following entry. */
|
||||||
|
@ -645,7 +643,7 @@ void gossip_store_mark_channel_deleted(struct gossip_store *gs,
|
||||||
const struct short_channel_id *scid)
|
const struct short_channel_id *scid)
|
||||||
{
|
{
|
||||||
gossip_store_add(gs, towire_gossip_store_delete_chan(tmpctx, scid),
|
gossip_store_add(gs, towire_gossip_store_delete_chan(tmpctx, scid),
|
||||||
0, false, false, false, NULL);
|
0, false, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_zombie(struct gossip_store *gs,
|
static void mark_zombie(struct gossip_store *gs,
|
||||||
|
|
|
@ -46,7 +46,7 @@ u64 gossip_store_add_private_update(struct gossip_store *gs, const u8 *update);
|
||||||
* (for appending amounts to channel_announcements for internal use).
|
* (for appending amounts to channel_announcements for internal use).
|
||||||
*/
|
*/
|
||||||
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
||||||
u32 timestamp, bool push, bool zombie, bool spam,
|
u32 timestamp, bool zombie, bool spam,
|
||||||
const u8 *addendum);
|
const u8 *addendum);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,6 @@ static void force_node_announce_rexmit(struct routing_state *rstate,
|
||||||
struct node *node)
|
struct node *node)
|
||||||
{
|
{
|
||||||
const u8 *announce;
|
const u8 *announce;
|
||||||
bool is_local = node_id_eq(&node->id, &rstate->local_id);
|
|
||||||
announce = gossip_store_get(tmpctx, rstate->gs, node->bcast.index);
|
announce = gossip_store_get(tmpctx, rstate->gs, node->bcast.index);
|
||||||
|
|
||||||
u32 initial_bcast_index = node->bcast.index;
|
u32 initial_bcast_index = node->bcast.index;
|
||||||
|
@ -468,7 +467,6 @@ static void force_node_announce_rexmit(struct routing_state *rstate,
|
||||||
node->bcast.index = gossip_store_add(rstate->gs,
|
node->bcast.index = gossip_store_add(rstate->gs,
|
||||||
announce,
|
announce,
|
||||||
node->bcast.timestamp,
|
node->bcast.timestamp,
|
||||||
is_local,
|
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -482,7 +480,6 @@ static void force_node_announce_rexmit(struct routing_state *rstate,
|
||||||
node->rgraph.index = gossip_store_add(rstate->gs,
|
node->rgraph.index = gossip_store_add(rstate->gs,
|
||||||
announce,
|
announce,
|
||||||
node->rgraph.timestamp,
|
node->rgraph.timestamp,
|
||||||
is_local,
|
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -852,7 +849,6 @@ static void add_channel_announce_to_broadcast(struct routing_state *rstate,
|
||||||
chan->bcast.index = gossip_store_add(rstate->gs,
|
chan->bcast.index = gossip_store_add(rstate->gs,
|
||||||
channel_announce,
|
channel_announce,
|
||||||
chan->bcast.timestamp,
|
chan->bcast.timestamp,
|
||||||
is_local,
|
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
addendum);
|
addendum);
|
||||||
|
@ -1538,7 +1534,6 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||||
chan->bcast.index =
|
chan->bcast.index =
|
||||||
gossip_store_add(rstate->gs, zombie_announcement,
|
gossip_store_add(rstate->gs, zombie_announcement,
|
||||||
chan->bcast.timestamp,
|
chan->bcast.timestamp,
|
||||||
local_direction(rstate, chan, NULL),
|
|
||||||
false, false, zombie_addendum);
|
false, false, zombie_addendum);
|
||||||
/* Deletion of the old addendum is optional. */
|
/* Deletion of the old addendum is optional. */
|
||||||
/* This opposing channel_update has been stashed away. Now that
|
/* This opposing channel_update has been stashed away. Now that
|
||||||
|
@ -1562,13 +1557,11 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||||
chan->half[!direction].bcast.index =
|
chan->half[!direction].bcast.index =
|
||||||
gossip_store_add(rstate->gs, zombie_update[0],
|
gossip_store_add(rstate->gs, zombie_update[0],
|
||||||
chan->half[!direction].bcast.timestamp,
|
chan->half[!direction].bcast.timestamp,
|
||||||
local_direction(rstate, chan, NULL),
|
|
||||||
false, false, NULL);
|
false, false, NULL);
|
||||||
if (zombie_update[1])
|
if (zombie_update[1])
|
||||||
chan->half[!direction].rgraph.index =
|
chan->half[!direction].rgraph.index =
|
||||||
gossip_store_add(rstate->gs, zombie_update[1],
|
gossip_store_add(rstate->gs, zombie_update[1],
|
||||||
chan->half[!direction].rgraph.timestamp,
|
chan->half[!direction].rgraph.timestamp,
|
||||||
local_direction(rstate, chan, NULL),
|
|
||||||
false, true, NULL);
|
false, true, NULL);
|
||||||
else
|
else
|
||||||
chan->half[!direction].rgraph.index = chan->half[!direction].bcast.index;
|
chan->half[!direction].rgraph.index = chan->half[!direction].bcast.index;
|
||||||
|
@ -1587,7 +1580,6 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||||
} else {
|
} else {
|
||||||
hc->rgraph.index
|
hc->rgraph.index
|
||||||
= gossip_store_add(rstate->gs, update, timestamp,
|
= gossip_store_add(rstate->gs, update, timestamp,
|
||||||
local_direction(rstate, chan, NULL),
|
|
||||||
zombie, spam, NULL);
|
zombie, spam, NULL);
|
||||||
if (hc->bcast.timestamp > rstate->last_timestamp
|
if (hc->bcast.timestamp > rstate->last_timestamp
|
||||||
&& hc->bcast.timestamp < time_now().ts.tv_sec)
|
&& hc->bcast.timestamp < time_now().ts.tv_sec)
|
||||||
|
@ -1910,8 +1902,6 @@ bool routing_add_node_announcement(struct routing_state *rstate,
|
||||||
} else {
|
} else {
|
||||||
node->rgraph.index
|
node->rgraph.index
|
||||||
= gossip_store_add(rstate->gs, msg, timestamp,
|
= gossip_store_add(rstate->gs, msg, timestamp,
|
||||||
node_id_eq(&node_id,
|
|
||||||
&rstate->local_id),
|
|
||||||
false, spam, NULL);
|
false, spam, NULL);
|
||||||
if (node->bcast.timestamp > rstate->last_timestamp
|
if (node->bcast.timestamp > rstate->last_timestamp
|
||||||
&& node->bcast.timestamp < time_now().ts.tv_sec)
|
&& node->bcast.timestamp < time_now().ts.tv_sec)
|
||||||
|
@ -2144,7 +2134,7 @@ bool routing_add_private_channel(struct routing_state *rstate,
|
||||||
capacity,
|
capacity,
|
||||||
chan_ann);
|
chan_ann);
|
||||||
index = gossip_store_add(rstate->gs, msg, 0, false, false,
|
index = gossip_store_add(rstate->gs, msg, 0, false, false,
|
||||||
false, NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
chan->bcast.index = index;
|
chan->bcast.index = index;
|
||||||
return true;
|
return true;
|
||||||
|
@ -2289,7 +2279,7 @@ void routing_channel_spent(struct routing_state *rstate,
|
||||||
|
|
||||||
/* Save to gossip_store in case we restart */
|
/* Save to gossip_store in case we restart */
|
||||||
msg = towire_gossip_store_chan_dying(tmpctx, &chan->scid, deadline);
|
msg = towire_gossip_store_chan_dying(tmpctx, &chan->scid, deadline);
|
||||||
index = gossip_store_add(rstate->gs, msg, 0, false, false, false, NULL);
|
index = gossip_store_add(rstate->gs, msg, 0, false, false, NULL);
|
||||||
|
|
||||||
/* Remember locally so we can kill it in 12 blocks */
|
/* Remember locally so we can kill it in 12 blocks */
|
||||||
status_debug("channel %s closing soon due"
|
status_debug("channel %s closing soon due"
|
||||||
|
|
|
@ -61,7 +61,7 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
|
||||||
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
||||||
/* Generated stub for gossip_store_add */
|
/* Generated stub for gossip_store_add */
|
||||||
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
||||||
u32 timestamp UNNEEDED, bool push UNNEEDED, bool zombie UNNEEDED, bool spam UNNEEDED,
|
u32 timestamp UNNEEDED, bool zombie UNNEEDED, bool spam UNNEEDED,
|
||||||
const u8 *addendum UNNEEDED)
|
const u8 *addendum UNNEEDED)
|
||||||
{ fprintf(stderr, "gossip_store_add called!\n"); abort(); }
|
{ fprintf(stderr, "gossip_store_add called!\n"); abort(); }
|
||||||
/* Generated stub for gossip_store_add_private_update */
|
/* Generated stub for gossip_store_add_private_update */
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
|
||||||
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
||||||
/* Generated stub for gossip_store_add */
|
/* Generated stub for gossip_store_add */
|
||||||
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
||||||
u32 timestamp UNNEEDED, bool push UNNEEDED, bool zombie UNNEEDED, bool spam UNNEEDED,
|
u32 timestamp UNNEEDED, bool zombie UNNEEDED, bool spam UNNEEDED,
|
||||||
const u8 *addendum UNNEEDED)
|
const u8 *addendum UNNEEDED)
|
||||||
{ fprintf(stderr, "gossip_store_add called!\n"); abort(); }
|
{ fprintf(stderr, "gossip_store_add called!\n"); abort(); }
|
||||||
/* Generated stub for gossip_store_add_private_update */
|
/* Generated stub for gossip_store_add_private_update */
|
||||||
|
|
Loading…
Add table
Reference in a new issue