-
Notifications
You must be signed in to change notification settings - Fork 4
feat: refactor domain objects deserialization #29
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
Conversation
ca414d2
to
b79341e
Compare
b79341e
to
108b784
Compare
108b784
to
a9b5c95
Compare
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.
Pull Request Overview
This PR refactors domain object deserialization and updates several factory and API calls. Key changes include:
- Using the new deserialization routine for transactions with kth::domain::chain::transaction::from_data.
- Replacing many calls from kth::domain::create with kth::domain::create_old and removing the witness parameter from several asynchronous and synchronous API calls.
- Commenting out deprecated functions (e.g. sighash functions and a mutable operation deserialization).
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/chain/transaction.cpp | Updated transaction deserialization and commented out deprecated sighash APIs. |
src/chain/token_data.cpp | Updated token encoding namespace usage. |
src/chain/output.cpp | Changed factory creation to use create_old for outputs. |
src/chain/operation.cpp | Commented out the mutable operation from_data function. |
src/chain/input.cpp | Updated input factory to use create_old with an extra parameter. |
src/chain/header.cpp | Updated header factory to use create_old. |
src/chain/chain_sync.cpp | Removed witness parameters from fetch and mempool API calls. |
src/chain/chain_async.cpp | Removed witness parameters from asynchronous fetch calls. |
src/chain/block.cpp | Updated block factory to use create_old. |
include/kth/capi/chain/transaction.h | Commented out deprecated sighash functions. |
include/kth/capi/chain/operation.h | Commented out the deprecated mutable operation function. |
conanfile.py | Bumped Catch2 version from 3.6.0 to 3.7.1. |
Comments suppressed due to low confidence (15)
src/chain/output.cpp:101
- [nitpick] Usage of 'create_old' suggests legacy behavior; confirm that this use is intentional and document the expected migration plan if applicable.
auto output = kth::domain::create_old<kth::domain::chain::output>(data_cpp);
src/chain/input.cpp:32
- [nitpick] Usage of 'create_old' with an extra parameter might denote backward compatibility; ensure the rationale is documented for future maintainers.
auto input = kth::domain::create_old<kth::domain::chain::input>(data_cpp, true);
src/chain/header.cpp:16
- [nitpick] Consider documenting why 'create_old' is used here instead of the newer API to avoid confusion for future code updates.
auto header = kth::domain::create_old<kth::domain::chain::header>(data_cpp);
src/chain/block.cpp:29
- [nitpick] Ensure that using 'create_old' for block creation is aligned with the planned refactor strategy and document any differences from the new API.
auto block = kth::domain::create_old<kth::domain::chain::block>(data_cpp);
src/chain/chain_sync.cpp:123
- The witness parameter has been removed in this fetch_block call; verify that the new API behavior remains correct and no required data is omitted.
safe_chain(chain).fetch_block(height, [&](std::error_code const& ec, kth::domain::message::block::const_ptr block, size_t h) {
src/chain/chain_sync.cpp:145
- Removing the witness parameter in the hash-based fetch_block call needs to be double-checked against the updated API design.
safe_chain(chain).fetch_block(hash_cpp, [&](std::error_code const& ec, kth::domain::message::block::const_ptr block, size_t h) {
src/chain/chain_sync.cpp:283
- Ensure that removing the witness parameter in fetch_transaction does not affect transaction validation behavior.
safe_chain(chain).fetch_transaction(hash_cpp, kth::int_to_bool(require_confirmed), [&](std::error_code const& ec, kth::domain::message::transaction::const_ptr transaction, size_t i, size_t h) {
src/chain/chain_sync.cpp:378
- Removing the witness parameter from get_mempool_transactions should be verified to ensure consistency with other API calls and expected mempool behavior.
auto txs = safe_chain(chain).get_mempool_transactions(address_cpp.encoded_cashaddr(false), kth::int_to_bool(use_testnet_rules));
src/chain/chain_sync.cpp:388
- Similarly, check that the removal of the witness parameter in get_mempool_transactions_from_wallets aligns with the updated API definition.
auto txs = safe_chain(chain).get_mempool_transactions_from_wallets(addresses_cpp, kth::int_to_bool(use_testnet_rules));
src/chain/chain_async.cpp:83
- Confirm that the removal of kth::witness from the asynchronous fetch_block call is valid and does not change the intended behavior.
safe_chain(chain).fetch_block(height, [chain, ctx, handler](std::error_code const& ec, kth::domain::message::block::const_ptr block, size_t h) {
src/chain/chain_async.cpp:90
- Make sure the asynchronous block fetch by hash without the witness parameter remains compatible with the underlying API requirements.
safe_chain(chain).fetch_block(hash_cpp, [chain, ctx, handler](std::error_code const& ec, kth::domain::message::block::const_ptr block, size_t h) {
src/chain/chain_async.cpp:143
- Verify that the updated asynchronous fetch_transaction call without the witness parameter still meets the API's data requirements.
safe_chain(chain).fetch_transaction(hash_cpp, kth::int_to_bool(require_confirmed), [chain, ctx, handler](std::error_code const& ec, kth::domain::message::transaction::const_ptr transaction, size_t i, size_t h) {
src/chain/operation.cpp:49
- Deprecating the mutable operation deserialization function is acceptable if all callers have been updated; otherwise, consider a migration strategy.
// kth_bool_t kth_chain_operation_from_data_mutable(kth_operation_t operation, uint8_t const* data, kth_size_t n) {
include/kth/capi/chain/transaction.h:46
- Commenting out the sighash functions indicates deprecation; ensure that downstream consumers are aware of the API change and have migrated accordingly.
// kth_hash_t kth_chain_transaction_hash_sighash_type(kth_transaction_t transaction, uint32_t sighash_type);
include/kth/capi/chain/operation.h:41
- Ensure that the deprecation of the mutable operation function is clearly communicated in the documentation to avoid confusion.
// kth_bool_t kth_chain_operation_from_data_mutable(kth_operation_t operation, uint8_t const* data, kth_size_t n);
No description provided.