-
Notifications
You must be signed in to change notification settings - Fork 49
warn if bitcoind is still in IBD #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/datum_blocktemplates.c
Outdated
| // fetch latest template | ||
| snprintf(gbt_req, sizeof(gbt_req), "{\"method\":\"getblocktemplate\",\"params\":[{\"rules\":[\"segwit\"]}],\"id\":%"PRIu64"}",(uint64_t)((uint64_t)time(NULL)<<(uint64_t)8)|(uint64_t)(i&255)); | ||
| gbt = bitcoind_json_rpc_call(tcurl, &datum_config, gbt_req); | ||
| gbt = bitcoind_json_rpc_call(tcurl, &datum_config, gbt_req, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're not going to set FAILONERROR, we should be checking the return code here somewhere instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I do below?
if ((int)json_integer_value(code_val) == -10) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HTTP return code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking for a way to not touch FAILONERROR but there is something I don't understand, why do datum return the HTTP code 500 while curl ... -w "%{http_code}\n" return 200 on the same syncing node?
2025-08-27 15:12:59.975 [ json_rpc_call_full] DEBUG: JSON decode failed(-1): wrong arguments
2025-08-27 15:12:59.975 [ datum_gateway_template_thread] ERROR: Could not fetch new template from http://localhost:8332!
2025-08-27 15:13:01.102 [ json_rpc_call_full] DEBUG: json_rpc_call: HTTP request failed: The requested URL returned error: 500
2025-08-27 15:13:01.102 [ json_rpc_call_full] DEBUG: json_rpc_call: Request was: {"method":"getblocktemplate","params":[{"rules":["segwit"]}],"id":449614740504}
curl --user <user> --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "getblocktemplate", "params": [{"rules": ["segwit"]}]}' -H 'content-type: application/json' http://127.0.0.1:8332/ -w "%{http_code}\n"
Enter host password for user '<user>': <password>
{"jsonrpc":"2.0","error":{"code":-10,"message":"Bitcoin Knots is in initial sync and waiting for blocks..."},"id":"curltest"}
200
src/datum_jsonrpc.h
Outdated
| bool update_rpc_cookie(global_config_t *cfg); | ||
| void update_rpc_auth(global_config_t *cfg); | ||
| json_t *bitcoind_json_rpc_call(CURL *curl, global_config_t *cfg, const char *rpc_req); | ||
| json_t *bitcoind_json_rpc_call(CURL *curl, global_config_t *cfg, const char *rpc_req, int failonerror); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it makes sense to pass failonerror (IMO it doesn't), it should be a bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? that an easy way to not affect other call?
Could be very usefull for the upcoming datum-gateway package for the debian official package distribution.