Skip to content

Remove ChainOracle trait by inverting dependency #1816

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

Open
LLFourn opened this issue Jan 31, 2025 · 0 comments
Open

Remove ChainOracle trait by inverting dependency #1816

LLFourn opened this issue Jan 31, 2025 · 0 comments
Labels
discussion There's still a discussion ongoing

Comments

@LLFourn
Copy link
Contributor

LLFourn commented Jan 31, 2025

The ChainOracle trait is annoying. Initially designed to allow anyone to provide their own view of the chain. This is a noble goal but doing this via a trait means we force the ChainOracle to do it synchronously and have to handle errors from the ChainOracle.

ChainOracles are really only used for canonicalization. Instead of writing:

tx_graph.list_canonical_txs(&local_chain, chain_tip);

We could instead write:

let list_txs_task = tx_graph.list_canonical_txs(chain_tip);
let txs_iter = local_chain.canonicalize(list_txs_task);

Now if we want to replace the canonicalizing functionality with a bitcoin node or a CBF system. It can be sync or async, infallible or fallible and we don't have to care in BDK.

@LLFourn LLFourn added the discussion There's still a discussion ongoing label Jan 31, 2025
@LLFourn LLFourn changed the title Remove ChainOracle by inverting dependency Remove ChainOracle trait by inverting dependency Jan 31, 2025
@notmandatory notmandatory moved this to Discussion in BDK Chain Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion There's still a discussion ongoing
Projects
Status: Discussion
Development

No branches or pull requests

1 participant