[noise] Keep only the slot flag test inline in the api loop

The per tick check is a byte load and branch now; the network check,
client scan and refill live in prepare_spare_ephemeral_slow_(), called
only while the slot is empty.
This commit is contained in:
J. Nick Koston
2026-09-07 12:23:09 +02:00
parent 5747c736c2
commit 866574ca14
2 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -199,8 +199,8 @@ void APIServer::loop() {
#ifdef USE_API_NOISE
// Refill only while no api client is still connecting; an OTA handshake is
// not visible here and just pays the refill it triggered.
void APIServer::prepare_spare_ephemeral_() {
if (noise::has_spare_ephemeral() || !network::is_connected()) {
void APIServer::prepare_spare_ephemeral_slow_() {
if (!network::is_connected()) {
return;
}
const uint32_t now = App.get_loop_component_start_time();
+7 -1
View File
@@ -364,7 +364,13 @@ class APIServer final : public Component,
#endif
#ifdef USE_API_NOISE
void prepare_spare_ephemeral_();
// Polled every loop tick: only the flag test stays inline
void prepare_spare_ephemeral_() {
if (!noise::has_spare_ephemeral()) {
this->prepare_spare_ephemeral_slow_();
}
}
void prepare_spare_ephemeral_slow_();
noise::NoiseContext noise_ctx_;
#ifndef USE_API_NOISE_PSK_FROM_YAML
SavedNoisePsk saved_psk_{}; // backs noise_ctx_ for a runtime provisioned key