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

Function next_msg_for_peer

connectd/multiplex.c:1269–1301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1267}
1268
1269static const u8 *next_msg_for_peer(struct peer *peer)
1270{
1271 const u8 *msg;
1272
1273 msg = msg_dequeue(peer->peer_outq);
1274 if (msg) {
1275 if (is_urgent(fromwire_peektype(msg))) {
1276 peer->peer_out_urgent--;
1277 }
1278 } else {
1279 /* Nothing in queue means nothing urgent in queue, surely! */
1280 assert(peer->peer_out_urgent == 0);
1281
1282 /* Draining? Don't send gossip. */
1283 if (peer->draining_state == WRITING_TO_PEER)
1284 return NULL;
1285
1286 /* If they want us to send gossip, do so now. */
1287 msg = maybe_gossip_msg(NULL, peer);
1288 if (!msg)
1289 return NULL;
1290 }
1291
1292 /* dev_disconnect can disable writes (discard everything) */
1293 if (peer->dev_writes_enabled) {
1294 if (*peer->dev_writes_enabled == 0) {
1295 return tal_free(msg);
1296 }
1297 (*peer->dev_writes_enabled)--;
1298 }
1299
1300 return msg;
1301}
1302
1303static void nonurgent_flush(struct peer *peer)
1304{

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