Browse Source

gossipd: implement broadcast_del to delete a specific index.

Required if we want to reorder node_announcement broadcasts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
def18a7bc1
  1. 8
      gossipd/broadcast.c
  2. 3
      gossipd/broadcast.h
  3. 3
      gossipd/test/run-bench-find_route.c
  4. 3
      gossipd/test/run-find_route-specific.c
  5. 3
      gossipd/test/run-find_route.c

8
gossipd/broadcast.c

@ -21,10 +21,16 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx)
return bstate;
}
void broadcast_del(struct broadcast_state *bstate, u64 index, const u8 *payload)
{
const struct queued_message *q = uintmap_del(&bstate->broadcasts, index);
assert(q->payload == payload);
}
static void destroy_queued_message(struct queued_message *msg,
struct broadcast_state *bstate)
{
uintmap_del(&bstate->broadcasts, msg->index);
broadcast_del(bstate, msg->index, msg->payload);
}
static struct queued_message *new_queued_message(const tal_t *ctx,

3
gossipd/broadcast.h

@ -20,6 +20,9 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx);
u64 insert_broadcast(struct broadcast_state *bstate, const u8 *msg,
u32 timestamp);
/* Manually delete a broadcast: not usually needed, since destructor does it */
void broadcast_del(struct broadcast_state *bstate, u64 index, const u8 *payload);
/* Return the broadcast with index >= *last_index, timestamp >= min and <= max
* and update *last_index.
* There's no broadcast with index 0. */

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

@ -56,6 +56,9 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
}
/* AUTOGENERATED MOCKS START */
/* Generated stub for broadcast_del */
void broadcast_del(struct broadcast_state *bstate UNNEEDED, u64 index UNNEEDED, const u8 *payload UNNEEDED)
{ fprintf(stderr, "broadcast_del called!\n"); abort(); }
/* Generated stub for fromwire_channel_announcement */
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }

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

@ -20,6 +20,9 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
}
/* AUTOGENERATED MOCKS START */
/* Generated stub for broadcast_del */
void broadcast_del(struct broadcast_state *bstate UNNEEDED, u64 index UNNEEDED, const u8 *payload UNNEEDED)
{ fprintf(stderr, "broadcast_del called!\n"); abort(); }
/* Generated stub for fromwire_channel_announcement */
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }

3
gossipd/test/run-find_route.c

@ -18,6 +18,9 @@ void status_fmt(enum log_level level UNUSED, const char *fmt, ...)
}
/* AUTOGENERATED MOCKS START */
/* Generated stub for broadcast_del */
void broadcast_del(struct broadcast_state *bstate UNNEEDED, u64 index UNNEEDED, const u8 *payload UNNEEDED)
{ fprintf(stderr, "broadcast_del called!\n"); abort(); }
/* Generated stub for fromwire_channel_announcement */
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }

Loading…
Cancel
Save