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

Function do_write_wire_header

wire/wire_io.c:97–113  ·  view source on GitHub ↗

arg->u2.s contains length we've written, arg->u1 contains u8 *data. */

Source from the content-addressed store, hash-verified

95
96/* arg->u2.s contains length we've written, arg->u1 contains u8 *data. */
97static int do_write_wire_header(int fd, struct io_plan_arg *arg)
98{
99 ssize_t ret;
100 size_t len = arg->u2.s & ~INSIDE_HEADER_BIT;
101 wire_len_t hdr = cpu_to_wirelen(tal_count(arg->u1.const_vp));
102
103 ret = write(fd, (char *)&hdr + len, HEADER_LEN - len);
104 if (ret <= 0)
105 return -1;
106 arg->u2.s += ret;
107
108 /* Both bytes written? Set up for normal write of data. */
109 if (arg->u2.s == INSIDE_HEADER_BIT + HEADER_LEN)
110 arg->u2.s = 0;
111
112 return 0;
113}
114
115static int do_write_wire(int fd, struct io_plan_arg *arg)
116{

Callers 1

do_write_wireFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected