-
Notifications
You must be signed in to change notification settings - Fork 406
refactor(chain)!: replace CanonicalIter
with sans-io CanonicalizationTask
#2038
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
oleonardolima
wants to merge
9
commits into
bitcoindevkit:master
Choose a base branch
from
oleonardolima:refactor/canonical-iter-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
342ef97
refactor(chain)!: replace `CanonicalIter` with sans-io `Canonicalizat…
oleonardolima 8020652
refactor(chain)!: optimize anchor checking in `CanonicalizationTask`
oleonardolima 8295104
refactor(chain)!: migrate from `CanonicalIter` to `CanonicalizationTask`
oleonardolima 7d9e65f
refactor(chain)!: complete removal of `canonical_iter` module
oleonardolima 2f4eaad
refactor(core,chain)!: extract generic `ChainQuery` trait from `Canon…
oleonardolima 0db5a20
refactor(chain)!: generalize `ChainQuery` trait with generic type
oleonardolima b7847bc
refactor(chain): use single queue for anchored txs in canonicalization
oleonardolima bc2884b
refactor(chain): make `LocalChain::canonicalize()` generic over `Chai…
oleonardolima 88a99ba
refactor(chain): restructure canonicalization with staged processing
oleonardolima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! Generic trait for query-based operations that require external blockchain data. | ||
//! | ||
//! The [`ChainQuery`] trait provides a standardized interface for implementing | ||
//! algorithms that need to make queries to blockchain sources and process responses | ||
//! in a sans-IO manner. | ||
|
||
/// A trait for types that perform query-based operations against blockchain data. | ||
/// | ||
/// This trait enables types to request blockchain information via queries and process | ||
/// responses in a decoupled, sans-IO manner. It's particularly useful for algorithms | ||
/// that need to interact with blockchain oracles, chain sources, or other blockchain | ||
/// data providers without directly performing I/O. | ||
/// | ||
/// # Type Parameters | ||
/// | ||
/// * `Request` - The type of query request that can be made | ||
/// * `Response` - The type of response expected for queries | ||
/// * `Context` - The type of context needed for finalization (e.g., `BlockId` for chain tip) | ||
/// * `Result` - The final result type produced when the query process is complete | ||
pub trait ChainQuery { | ||
/// The type of query request that can be made. | ||
type Request; | ||
|
||
/// The type of response expected for queries. | ||
type Response; | ||
|
||
/// The type of context needed for finalization. | ||
/// | ||
/// This could be `BlockId` for algorithms needing chain tip information, | ||
/// `()` for algorithms that don't need additional context, or any other | ||
/// type specific to the implementation's needs. | ||
type Context; | ||
|
||
/// The final result type produced when the query process is complete. | ||
type Result; | ||
|
||
/// Returns the next query needed, if any. | ||
/// | ||
/// This method should return `Some(request)` if more information is needed, | ||
/// or `None` if no more queries are required. | ||
fn next_query(&mut self) -> Option<Self::Request>; | ||
|
||
/// Resolves a query with the given response. | ||
/// | ||
/// This method processes the response to a previous query request and updates | ||
/// the internal state accordingly. | ||
fn resolve_query(&mut self, response: Self::Response); | ||
|
||
/// Returns true if the query process is complete and ready to finish. | ||
/// | ||
/// The default implementation returns `true` when there are no more queries needed. | ||
/// Implementors can override this for more specific behavior if needed. | ||
fn is_finished(&mut self) -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, this doesn't need to be |
||
self.next_query().is_none() | ||
} | ||
|
||
/// Completes the query process and returns the final result. | ||
/// | ||
/// This method should be called when `is_finished` returns `true`. | ||
/// It consumes `self` and produces the final result. | ||
/// | ||
/// The `context` parameter provides implementation-specific context | ||
/// needed for finalization. | ||
fn finish(self, context: Self::Context) -> Self::Result; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,6 @@ mod merge; | |
pub use merge::*; | ||
|
||
pub mod spk_client; | ||
|
||
mod chain_query; | ||
pub use chain_query::*; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.