Skip to content

Commit

Permalink
Merge branch '189-nodelist-update-endless-loop' into 'develop'
Browse files Browse the repository at this point in the history
Resolve "Nodelist update endless loop"

Closes #189

See merge request in3/c/in3-core!119
  • Loading branch information
simon-jentzsch committed Feb 6, 2020
2 parents 2df3dff + f07771c commit ac17f21
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/client/nodelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ node_match_t* in3_node_list_fill_weight(in3_t* c, chain_id_t chain_id, in3_node_
return first;
}

bool update_in_progress(const in3_ctx_t* ctx) {
const char* required_method = d_get_stringk(ctx->requests[0], K_METHOD);
return (required_method && strcmp(required_method, "in3_nodeList") == 0);
}

in3_ret_t in3_node_list_get(in3_ctx_t* ctx, chain_id_t chain_id, bool update, in3_node_t** nodelist, int* nodelist_length, in3_node_weight_t** weights) {
in3_ret_t res = IN3_EFIND;
in3_chain_t* chain = in3_find_chain(ctx->client, chain_id);
Expand All @@ -416,12 +421,16 @@ in3_ret_t in3_node_list_get(in3_ctx_t* ctx, chain_id_t chain_id, bool update, in
if (chain->nodelist_upd8_params && !chain->nodelist_upd8_params->exp_last_block) {
_free(chain->nodelist_upd8_params);
chain->nodelist_upd8_params = NULL;
} else if (update_in_progress(ctx)) {
goto SKIP_UPDATE;
}

// now update the nodeList
res = update_nodelist(ctx->client, chain, ctx);
if (res < 0) return res;
}

SKIP_UPDATE:
// do we need to update the whiitelist?
if (chain->whitelist // only if we have a whitelist
&& (chain->whitelist->needs_update || update || ctx_find_required(ctx, "in3_whiteList")) // which has the needs_update-flag (or forced) or we have already sent the request and are now picking up the result
Expand Down

0 comments on commit ac17f21

Please sign in to comment.