-
Notifications
You must be signed in to change notification settings - Fork 26
Implement version specific types #116
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
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.
Looking good mate. I wouldn't personally bother pruning at the moment. At this stage just checking that the returned data is the correct shape is enough.
I have effected the changes reviewed, please do have a check when you are chanced. |
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.
Getting there man, keep at it.
Changes effected... Thank you so much for all the reviews, I am really learning and understanding the codebase more. |
I just introduced a new style of writing test code in #125. Please follow the same style when you write your new tests. Thanks man! |
Alright, I will check it out... Thank you :). |
def6957
to
392c684
Compare
0f349df
to
a5cc879
Compare
You got a rebase mistake in there mate. In |
In case its useful to you I have this alias which mc
mc: aliased to git grep -l '<<<<' Then I use |
This is going to be hard for me to review because its so big but also I appreciate that it is hard to work on this crate without doing big changesets so I'm happy to review this but there may be a few iterations. |
Some things I found:
let json: VerifyTxOutProof = node.client.verify_tx_out_proof(&proof)?;
let model: Result<mtype::VerifyTxOutProof, _> = json.into_model();
let txids = model.unwrap(); The point to this is to check that all the re-exports were done correctly. Or using let _: PruneBlockchain = node.client.prune_blockchain(target_height); It would probably be best to push up an initial patch that does just one method completely so I can review that and then you could do all the others as a second patch. Sorry I should have said that weeks ago, my bad. There is a way to stage code chunks so you can pull the changes out - let me know if you want more tips on that. |
a5cc879
to
eb52f15
Compare
Appreciate your efforts man, this is not the easiest crate to work on. Holla at me if you have any other questions. |
adeb378
to
6ac7abc
Compare
6ac7abc
to
0a5785c
Compare
Noted, thank you for spotting it out. |
No Problem, I will make all changes necessary as you review! :). |
True, almost forgot changing their status to done. Okayyy, now I see the reason why, for this particular methods, most of them returns I will also push up an initial patch with single method so you can review, before doing the others. I will look it up i.e. stage code chucks, and if there is anything I don't understand, I will definitely ask for clarity. Once again thank you always :). |
bbcec24 Implement pruneblock method and test (GideonBature) Pull request description: Going by the conversations with tcharding for PR #116 on implementing one method at a time for easier review: This is the first method implementation `pruneblockchain` which is a specific type that returns a standard type (numeric). Once this is approved, I’ll proceed with the remaining ones. ACKs for top commit: tcharding: ACK bbcec24 Tree-SHA512: 93b6dad6db42e6dad2c0e229553cc415f1d6c8b150dfda092f243b5ff61c7f8932878ee12d330915ca19e3b482c40d546c291692dad14980d9ac92e492f3dfbd
565702f Implement savemempool method and test (GideonBature) Pull request description: Going by the conversations with tcharding for PR #116 on implementing one method at a time for easier review: This is the second method implementation `savemempool` which is a specific type that returns a (json null). Once this is approved, I’ll proceed with the next one. ACKs for top commit: tcharding: ACK 565702f Tree-SHA512: 85d0d2ef8fa48cc325efc4f7eb9dfbf1276fe9185ff0c3bc2639aaec924088795638b82fb51856cd8454d24a7c59332297921ee00db38efb7e02db35bddbc1fc
ae286f1 Implement verifychain method and test (GideonBature) Pull request description: This is based on PR #116 on implementing one method at a time for easier review: This is the third method implementation: `verifychain` which returns a (bool type). Once this is approved, I’ll proceed with the next one. ACKs for top commit: tcharding: ACK ae286f1 Tree-SHA512: 9992984539ead8a63b394b431df0b52cf99d552d17c3c4930aa406660e1b51b5e43fc07e5bfeda1f7c9c0234278d212d42e2f893b97a7de1e208199bc8012aca
The `ScriptPubkey` type is a type that is returned by Core in various places. It seems like the Core devs put a fair bit of effort into it (probably because of this) and the when the type changed in v22 it was changed in a way that was completely backwards compatible. I failed to fully understand this when first adding the type. With this patch applied there is now only one `ScriptPubkey` type (in `libr.s`) and also we add an model type. The `ScriptPubkey` type is unusual in that its fields can be used to create `TxOut` if tx value is known - which for example in `GetTxOut` it is. So here we also remove the v22 `GetTxOut` type since it only existed because of the perceived difference in `ScriptPubkey` which no longer exists. Fix: rust-bitcoin#116
The `ScriptPubkey` type is a type that is returned by Core in various places. It seems like the Core devs put a fair bit of effort into it (probably because of this) and when the type changed in v22 it was changed in a way that was completely backwards compatible. I failed to fully understand this when first adding the type. With this patch applied there is now only one `ScriptPubkey` type (in `libr.s`) and also we add a model type. The `ScriptPubkey` type is unusual in that its fields can be used to create `TxOut` if tx value is known - which for example in `GetTxOut` it is. So here we also remove the v22 `GetTxOut` type since it only existed because of the perceived difference in `ScriptPubkey` which no longer exists. Fix: rust-bitcoin#116
Implement Version-Specific Types for Status
omitted
This PR addresses issue #115 by implementing the methods with status of
'omitted'
in methods with version-specific types. Previously,'omitted'
was used in cases where return types were standard or seemingly inconsequential (e.g.,null
, standard library types). However, this approach introduced a risk: if the return type of such methods changes in future Bitcoin Core versions, we would not catch it.To fix this, this PR:
Method::new_no_model
in corresponding methods.This improves type safety, clarity, and future-proofing of the client interface.
Summary of Work Done
🚀 Blockchain Methods
Tested with:
cargo test --features=28_0 --test blockchain
🌐 Network Methods
Tested with:
cargo test --features=28_0 --test network
💰 Wallet Methods
Tested with:
cargo test --features=28_0 --test wallet
✅ Ready for review
Closes #115