MCPcopy Create free account
hub / github.com/ElementsProject/lightning / maybe_from_gossip_store

Function maybe_from_gossip_store

connectd/multiplex.c:496–548  ·  view source on GitHub ↗

If we are streaming gossip, get something from gossip store */

Source from the content-addressed store, hash-verified

494
495/* If we are streaming gossip, get something from gossip store */
496static u8 *maybe_from_gossip_store(const tal_t *ctx, struct peer *peer)
497{
498 u8 *msg;
499
500 /* dev-mode can suppress all gossip */
501 if (IFDEV(peer->daemon->dev_suppress_gossip, false))
502 return NULL;
503
504 /* BOLT #7:
505 * - if the `gossip_queries` feature is negotiated:
506 * - MUST NOT relay any gossip messages it did not generate itself,
507 * unless explicitly requested.
508 */
509
510 /* So, even if they didn't send us a timestamp_filter message,
511 * we *still* send our own gossip. */
512 if (!peer->gs.gossip_timer) {
513 return gossip_store_next(ctx, &peer->daemon->gossip_store_fd,
514 0, 0xFFFFFFFF,
515 true,
516 false,
517 &peer->gs.off,
518 &peer->daemon->gossip_store_end);
519 }
520
521 /* Not streaming right now? */
522 if (!peer->gs.active)
523 return NULL;
524
525 /* This should be around to kick us every 60 seconds */
526 assert(peer->gs.gossip_timer);
527
528again:
529 msg = gossip_store_next(ctx, &peer->daemon->gossip_store_fd,
530 peer->gs.timestamp_min,
531 peer->gs.timestamp_max,
532 false,
533 false,
534 &peer->gs.off,
535 &peer->daemon->gossip_store_end);
536 /* Don't send back gossip they sent to us! */
537 if (msg) {
538 if (gossip_rcvd_filter_del(peer->gs.grf, msg)) {
539 msg = tal_free(msg);
540 goto again;
541 }
542 status_peer_io(LOG_IO_OUT, &peer->id, msg);
543 return msg;
544 }
545
546 peer->gs.active = false;
547 return NULL;
548}
549
550/* Mutual recursion */
551static void send_ping(struct peer *peer);

Callers 1

write_to_peerFunction · 0.85

Calls 4

gossip_store_nextFunction · 0.85
gossip_rcvd_filter_delFunction · 0.85
tal_freeFunction · 0.85
status_peer_ioFunction · 0.50

Tested by

no test coverage detected