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

Function sign_and_timestamp_update

gossipd/gossip_generation.c:455–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455static u8 *sign_and_timestamp_update(const tal_t *ctx,
456 struct daemon *daemon,
457 const struct chan *chan,
458 int direction,
459 u8 *unsigned_update TAKES)
460{
461 u8 *msg, *update;
462 be32 timestamp;
463 const u32 *prev_timestamp;
464 const struct half_chan *hc = &chan->half[direction];
465
466 if (is_halfchan_defined(hc))
467 prev_timestamp = &hc->bcast.timestamp;
468 else
469 prev_timestamp = NULL;
470
471 /* Get an appropriate timestamp */
472 timestamp = cpu_to_be32(timestamp_for_update(daemon,
473 prev_timestamp,
474 is_disabled(unsigned_update)));
475 memcpy(timestamp_access(unsigned_update), &timestamp, sizeof(timestamp));
476
477 /* Note that we treat the hsmd as synchronous. This is simple (no
478 * callback hell)!, but may need to change to async if we ever want
479 * remote HSMs */
480 if (!wire_sync_write(HSM_FD,
481 towire_hsmd_cupdate_sig_req(tmpctx, unsigned_update))) {
482 status_failed(STATUS_FAIL_HSM_IO, "Writing cupdate_sig_req: %s",
483 strerror(errno));
484 }
485
486 msg = wire_sync_read(tmpctx, HSM_FD);
487 if (!msg || !fromwire_hsmd_cupdate_sig_reply(ctx, msg, &update)) {
488 status_failed(STATUS_FAIL_HSM_IO,
489 "Reading cupdate_sig_req: %s",
490 strerror(errno));
491 }
492
493 if (taken(unsigned_update))
494 tal_free(unsigned_update);
495
496 /* Tell lightningd about this immediately (even if we're not actually
497 * applying it now). We choose not to send info about private
498 * channels, even in errors. */
499 if (is_chan_public(chan)) {
500 msg = towire_gossipd_got_local_channel_update(NULL, &chan->scid,
501 update);
502 daemon_conn_send(daemon->master, take(msg));
503 }
504
505 return update;
506}
507
508static u8 *create_unsigned_update(const tal_t *ctx,
509 const struct short_channel_id *scid,

Callers 2

defer_updateFunction · 0.85

Calls 15

is_halfchan_definedFunction · 0.85
cpu_to_be32Function · 0.85
timestamp_for_updateFunction · 0.85
is_disabledFunction · 0.85
timestamp_accessFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
is_chan_publicFunction · 0.85
wire_sync_writeFunction · 0.50
status_failedFunction · 0.50
wire_sync_readFunction · 0.50

Tested by

no test coverage detected