Skip to content

Commit

Permalink
common/cryptomsg: remove unused 'reading_body' flag and 'peer_in_star…
Browse files Browse the repository at this point in the history
…ted'.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Sep 28, 2018
1 parent 74ab212 commit dfaaa09
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
13 changes: 0 additions & 13 deletions common/cryptomsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ static struct io_plan *peer_decrypt_body(struct io_conn *conn,
struct io_plan *plan;
u8 *in, *decrypted;

pcs->reading_body = false;

decrypted = cryptomsg_decrypt_body(pcs->in, &pcs->cs, pcs->in);
if (!decrypted)
return io_close(conn);
Expand Down Expand Up @@ -202,8 +200,6 @@ static struct io_plan *peer_decrypt_header(struct io_conn *conn,

tal_free(pcs->in);

pcs->reading_body = true;

/* BOLT #8:
*
* 4. Read _exactly_ `l+16` bytes from the network buffer, and let
Expand All @@ -230,7 +226,6 @@ struct io_plan *peer_read_message(struct io_conn *conn,
*
* 1. Read _exactly_ 18 bytes from the network buffer.
*/
pcs->reading_body = false;
pcs->in = tal_arr(conn, u8, 18);
pcs->next_in = next;
return io_read(conn, pcs->in, 18, peer_decrypt_header, pcs);
Expand Down Expand Up @@ -384,16 +379,8 @@ struct io_plan *peer_write_message(struct io_conn *conn,
return io_write(conn, pcs->out, tal_count(pcs->out), post, pcs);
}

/* We read in two parts, so we might have started body. */
bool peer_in_started(const struct io_conn *conn,
const struct peer_crypto_state *cs)
{
return io_plan_in_started(conn) || cs->reading_body;
}

void init_peer_crypto_state(struct peer *peer, struct peer_crypto_state *pcs)
{
pcs->peer = peer;
pcs->out = pcs->in = NULL;
pcs->reading_body = false;
}
7 changes: 0 additions & 7 deletions common/cryptomsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ struct peer_crypto_state {
/* Peer who owns us: peer->crypto_state == this */
struct peer *peer;

/* Where we are up to in reading (we do in two parts). */
bool reading_body;

/* Output and input buffers. */
u8 *out, *in;
struct io_plan *(*next_in)(struct io_conn *, struct peer *, u8 *);
Expand All @@ -33,10 +30,6 @@ struct io_plan *peer_read_message(struct io_conn *conn,
struct peer *,
u8 *msg));

/* Have we already started reading a message? */
bool peer_in_started(const struct io_conn *conn,
const struct peer_crypto_state *cs);

/* Sends message: frees if taken(msg). */
struct io_plan *peer_write_message(struct io_conn *conn,
struct peer_crypto_state *cs,
Expand Down

0 comments on commit dfaaa09

Please sign in to comment.