| 567 | } |
| 568 | |
| 569 | static void apply_update(struct daemon *daemon, |
| 570 | const struct chan *chan, |
| 571 | int direction, |
| 572 | u8 *update TAKES) |
| 573 | { |
| 574 | u8 *msg; |
| 575 | struct peer *peer = find_peer(daemon, &chan->nodes[!direction]->id); |
| 576 | |
| 577 | if (!is_chan_public(chan)) { |
| 578 | /* Save and restore taken state, for handle_channel_update */ |
| 579 | bool update_taken = taken(update); |
| 580 | |
| 581 | /* handle_channel_update will not put private updates in the |
| 582 | * broadcast list, but we send it direct to the peer (if we |
| 583 | * have one connected) now */ |
| 584 | if (peer) |
| 585 | queue_peer_msg(peer, update); |
| 586 | |
| 587 | if (update_taken) |
| 588 | take(update); |
| 589 | } |
| 590 | |
| 591 | msg = handle_channel_update(daemon->rstate, update, peer, NULL, true); |
| 592 | if (msg) |
| 593 | status_failed(STATUS_FAIL_INTERNAL_ERROR, |
| 594 | "%s: rejected local channel update %s: %s", |
| 595 | __func__, |
| 596 | /* Normally we must not touch something taken() |
| 597 | * but we're in deep trouble anyway, and |
| 598 | * handle_channel_update only tal_steals onto |
| 599 | * tmpctx, so it's actually OK. */ |
| 600 | tal_hex(tmpctx, update), |
| 601 | tal_hex(tmpctx, msg)); |
| 602 | } |
| 603 | |
| 604 | static void sign_timestamp_and_apply_update(struct daemon *daemon, |
| 605 | const struct chan *chan, |
no test coverage detected