Browse Source

gossipd: remove unused queue_broadcast.

We only ever access broadcast via the index (which is way faster!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
060182fb65
  1. 31
      gossipd/broadcast.c
  2. 10
      gossipd/broadcast.h

31
gossipd/broadcast.c

@ -44,37 +44,6 @@ bool replace_broadcast(struct broadcast_state *bstate, u64 *index,
return evicted;
}
bool queue_broadcast(struct broadcast_state *bstate,
const int type,
const u8 *tag,
const u8 *payload)
{
struct queued_message *msg;
u64 index;
bool evicted = false;
memcheck(tag, tal_len(tag));
/* Remove any tag&type collisions */
for (msg = uintmap_first(&bstate->broadcasts, &index);
msg;
msg = uintmap_after(&bstate->broadcasts, &index)) {
if (msg->type == type &&
memeq(msg->tag, tal_len(msg->tag), tag, tal_len(tag))) {
uintmap_del(&bstate->broadcasts, index);
tal_free(msg);
evicted = true;
break;
}
}
/* Now add the message to the queue */
msg = new_queued_message(bstate, type, tag, payload);
uintmap_add(&bstate->broadcasts, bstate->next_index, msg);
bstate->next_index++;
return evicted;
}
struct queued_message *next_broadcast_message(struct broadcast_state *bstate, u64 last_index)
{
return uintmap_after(&bstate->broadcasts, &last_index);

10
gossipd/broadcast.h

@ -26,16 +26,6 @@ struct broadcast_state {
struct broadcast_state *new_broadcast_state(tal_t *ctx);
/* Queue a new message to be broadcast and replace any outdated
* broadcast. Replacement is done by comparing the `type` and the
* `tag`, if both match the old message is dropped from the queue. The
* new message is added to the top of the broadcast queue. Returns
* true if a previous entry with the same tag has been evicted. */
bool queue_broadcast(struct broadcast_state *bstate,
const int type,
const u8 *tag,
const u8 *payload);
/* Replace a queued message with @index, if it matches the type and
* tag for the new message. The new message will be queued with the
* next highest index. @index is updated to hold the index of the

Loading…
Cancel
Save