Skip to content

Commit 648c684

Browse files
Now accepts a network even if it already has it
1 parent c579897 commit 648c684

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src_features/provide_network_info/network_info.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ static bool handle_chain_id(const s_tlv_data *data, s_network_info_ctx *context)
9090
uint64_t chain_id;
9191
uint8_t buf[sizeof(chain_id)];
9292
uint64_t max_range;
93-
uint8_t i;
9493

9594
(void) context;
9695
if (data->length > sizeof(buf)) {
@@ -106,13 +105,6 @@ static bool handle_chain_id(const s_tlv_data *data, s_network_info_ctx *context)
106105
PRINTF("Unsupported chain ID: %u\n", chain_id);
107106
return false;
108107
}
109-
// Check if the chain_id is already registered
110-
for (i = 0; i < MAX_DYNAMIC_NETWORKS; i++) {
111-
if (DYNAMIC_NETWORK_INFO[i].chain_id == chain_id) {
112-
PRINTF("CHAIN_ID already exist!\n");
113-
return false;
114-
}
115-
}
116108
context->network.chain_id = chain_id;
117109
return true;
118110
}
@@ -282,6 +274,14 @@ bool verify_network_info_struct(const s_network_info_ctx *context) {
282274
return false;
283275
}
284276

277+
// Check if the chain ID is already registered, if so delete it silently to prevent duplicates
278+
for (int i = 0; i < MAX_DYNAMIC_NETWORKS; ++i) {
279+
if (DYNAMIC_NETWORK_INFO[i].chain_id == context->network.chain_id) {
280+
explicit_bzero(&DYNAMIC_NETWORK_INFO[i], sizeof(DYNAMIC_NETWORK_INFO[i]));
281+
break;
282+
}
283+
}
284+
285285
// Set the current slot here, because the corresponding icon will be received
286286
// separately, after the network configuration, and should keep the same slot
287287
g_current_network_slot = (g_current_network_slot + 1) % MAX_DYNAMIC_NETWORKS;

0 commit comments

Comments
 (0)