| 1171 | } |
| 1172 | |
| 1173 | static 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 | |
| 1207 | static void nonurgent_flush(struct peer *peer) |
| 1208 | { |
no test coverage detected