Close the connection if this fails */
| 516 | |
| 517 | /* Close the connection if this fails */ |
| 518 | static bool encrypt_append(struct peer *peer, const u8 *msg TAKES) |
| 519 | { |
| 520 | int type = fromwire_peektype(msg); |
| 521 | const u8 *enc; |
| 522 | size_t enclen; |
| 523 | |
| 524 | /* Special message type directing us to process batch items. */ |
| 525 | if (type == WIRE_PROTOCOL_BATCH_ELEMENT) { |
| 526 | enc = process_batch_elements(tmpctx, peer, msg); |
| 527 | if (!enc) |
| 528 | return false; |
| 529 | } else { |
| 530 | enc = cryptomsg_encrypt_msg(tmpctx, &peer->cs, msg); |
| 531 | } |
| 532 | enclen = tal_bytelen(enc); |
| 533 | memcpy(membuf_add(&peer->encrypted_peer_out, enclen), |
| 534 | enc, |
| 535 | enclen); |
| 536 | return true; |
| 537 | } |
| 538 | |
| 539 | static void pad_encrypted_queue(struct peer *peer) |
| 540 | { |
no test coverage detected