Skip to content

Exposed getblocktemplate rpc via REST endpoint.#230

Draft
Randy808 wants to merge 1 commit into
Blockstream:new-indexfrom
Randy808:add-getblocktemplate
Draft

Exposed getblocktemplate rpc via REST endpoint.#230
Randy808 wants to merge 1 commit into
Blockstream:new-indexfrom
Randy808:add-getblocktemplate

Conversation

@Randy808

Copy link
Copy Markdown
Collaborator

No description provided.

@Randy808 Randy808 requested a review from EddieHouston June 24, 2026 20:34
Comment thread src/rest.rs Outdated
Comment thread src/rest.rs
Comment thread src/rest.rs
}
}

fn getblocktemplate_rpc_error(err: &errors::Error) -> Option<(i64, String)> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex review finding:

The Connection error handling here probably will not behave as intended.
Daemon::request() retries ErrorKind::Connection internally, so this REST error path is unlikely to see those errors.

For example, bitcoind warmup error -28 is converted into ErrorKind::Connection, which means /getblocktemplate would keep retrying instead of returning the intended 502 JSON response.

One related concern: Query::getblocktemplate() holds the block template cache mutex while making the daemon RPC call. If that RPC gets stuck retrying, later /getblocktemplate requests will block behind the same mutex.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse_jsonrpc_reply was changed to just return the error if getblocktemplate is called. The same behavior should prob be applied to submitpackage too but I didn't want to change that function too much in this PR. The infinite retry behavior is only desirable for internal calls to the daemon, not externally invoked ones.

@EddieHouston EddieHouston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good. Currently I don't think that electrs directly proxies through any other calls to bitcoin node (although I was just considering it for calls to GET /block//raw... so electrs doesn't cache all the txs in the raw block).

We might also consider adding a startup flag (--enable-mining-rest) to enable this.

@Randy808 Randy808 force-pushed the add-getblocktemplate branch from 6f61218 to a812004 Compare June 25, 2026 14:45
@Randy808

Copy link
Copy Markdown
Collaborator Author

Added the --enable-mining-rest flag too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants