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

Function next_msg_for_peer

connectd/multiplex.c:1173–1205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1171}
1172
1173static const u8 *next_msg_for_peer(struct peer *peer)
1174{
1175 const u8 *msg;
1176
1177 msg = msg_dequeue(peer->peer_outq);
1178 if (msg) {
1179 if (is_urgent(fromwire_peektype(msg))) {
1180 peer->peer_out_urgent--;
1181 }
1182 } else {
1183 /* Nothing in queue means nothing urgent in queue, surely! */
1184 assert(peer->peer_out_urgent == 0);
1185
1186 /* Draining? Don't send gossip. */
1187 if (peer->draining_state == WRITING_TO_PEER)
1188 return NULL;
1189
1190 /* If they want us to send gossip, do so now. */
1191 msg = maybe_gossip_msg(NULL, peer);
1192 if (!msg)
1193 return NULL;
1194 }
1195
1196 /* dev_disconnect can disable writes (discard everything) */
1197 if (peer->dev_writes_enabled) {
1198 if (*peer->dev_writes_enabled == 0) {
1199 return tal_free(msg);
1200 }
1201 (*peer->dev_writes_enabled)--;
1202 }
1203
1204 return msg;
1205}
1206
1207static void nonurgent_flush(struct peer *peer)
1208{

Callers 1

write_to_peerFunction · 0.85

Calls 5

msg_dequeueFunction · 0.85
is_urgentFunction · 0.85
fromwire_peektypeFunction · 0.85
maybe_gossip_msgFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected