| 1267 | } |
| 1268 | |
| 1269 | static 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 | |
| 1303 | static void nonurgent_flush(struct peer *peer) |
| 1304 | { |
no test coverage detected