| 1241 | } |
| 1242 | |
| 1243 | static 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 | |
| 1277 | static void nonurgent_flush(struct peer *peer) |
| 1278 | { |
no test coverage detected