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

Function next_msg_for_peer

connectd/multiplex.c:1243–1275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241}
1242
1243static const u8 *next_msg_for_peer(struct peer *peer)
1244{
1245 const u8 *msg;
1246
1247 msg = msg_dequeue(peer->peer_outq);
1248 if (msg) {
1249 if (is_urgent(fromwire_peektype(msg))) {
1250 peer->peer_out_urgent--;
1251 }
1252 } else {
1253 /* Nothing in queue means nothing urgent in queue, surely! */
1254 assert(peer->peer_out_urgent == 0);
1255
1256 /* Draining? Don't send gossip. */
1257 if (peer->draining_state == WRITING_TO_PEER)
1258 return NULL;
1259
1260 /* If they want us to send gossip, do so now. */
1261 msg = maybe_gossip_msg(NULL, peer);
1262 if (!msg)
1263 return NULL;
1264 }
1265
1266 /* dev_disconnect can disable writes (discard everything) */
1267 if (peer->dev_writes_enabled) {
1268 if (*peer->dev_writes_enabled == 0) {
1269 return tal_free(msg);
1270 }
1271 (*peer->dev_writes_enabled)--;
1272 }
1273
1274 return msg;
1275}
1276
1277static void nonurgent_flush(struct peer *peer)
1278{

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