Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/lantern/networking/gossipsub_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct lantern_gossipsub_service {
};

void lantern_gossipsub_service_init(struct lantern_gossipsub_service *service);
void lantern_gossipsub_service_stop(struct lantern_gossipsub_service *service);
void lantern_gossipsub_service_reset(struct lantern_gossipsub_service *service);
int lantern_gossipsub_service_start(
struct lantern_gossipsub_service *service,
Expand Down
3 changes: 2 additions & 1 deletion src/core/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,7 @@ static void shutdown_genesis_and_network(struct lantern_client *client)
"client",
&(const struct lantern_log_metadata){.validator = client->node_id},
"shutdown: stopping gossipsub");
lantern_gossipsub_service_reset(&client->gossip);
lantern_gossipsub_service_stop(&client->gossip);
client->gossip_running = false;
lantern_log_info(
"client",
Expand All @@ -3275,6 +3275,7 @@ static void shutdown_genesis_and_network(struct lantern_client *client)
&(const struct lantern_log_metadata){.validator = client->node_id},
"shutdown: resetting libp2p host");
lantern_libp2p_host_reset(&client->network);
lantern_gossipsub_service_reset(&client->gossip);
lantern_log_info(
"client",
&(const struct lantern_log_metadata){.validator = client->node_id},
Expand Down
18 changes: 17 additions & 1 deletion src/networking/gossipsub_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void lantern_gossipsub_service_init(struct lantern_gossipsub_service *service) {
memset(service, 0, sizeof(*service));
}

void lantern_gossipsub_service_reset(struct lantern_gossipsub_service *service) {
static void lantern_gossipsub_service_remove_validators(struct lantern_gossipsub_service *service) {
if (!service) {
return;
}
Expand All @@ -738,8 +738,24 @@ void lantern_gossipsub_service_reset(struct lantern_gossipsub_service *service)
service->vote_validator_handle = NULL;
service->vote_subnet_validator_handle = NULL;
service->aggregated_attestation_validator_handle = NULL;
}

void lantern_gossipsub_service_stop(struct lantern_gossipsub_service *service) {
if (!service) {
return;
}
lantern_gossipsub_service_remove_validators(service);
if (service->gossipsub) {
libp2p_gossipsub_stop(service->gossipsub);
}
}

void lantern_gossipsub_service_reset(struct lantern_gossipsub_service *service) {
if (!service) {
return;
}
lantern_gossipsub_service_stop(service);
if (service->gossipsub) {
libp2p_gossipsub_free(service->gossipsub);
service->gossipsub = NULL;
}
Expand Down
Loading