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
Move merkleblock
into merkle_tree
#1374
Move merkleblock
into merkle_tree
#1374
Conversation
b48c7b5
to
6ff9d47
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.
Concept ACK, not sure about naming.
bitcoin/src/network/message.rs
Outdated
@@ -17,14 +17,13 @@ use io::Read as _; | |||
use crate::blockdata::block; | |||
use crate::blockdata::transaction; | |||
use crate::network::address::{Address, AddrV2Message}; | |||
use crate::network::{message_network, message_bloom}; | |||
use crate::network::{message_network, message_bloom, message_merkleblock}; |
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.
Why is the module called message_merkleblock
instead of just merkleblock
?
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.
To fit in with the names of all the others. FTR I think they all need renaming though.
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.
I could rename them all as an initial patch if that is desired?
I understand merkleblock as providing the structure used by the |
I think it's used both for supporting bloom filter style spv in the network layer and for the Network related use for rpc related use for Though since its use is for both rpc and network, maybe it's better to leave it in |
Thanks for bringing that to my attention, I missed the RPC usage when I did this.
We are trying to get rid of the
Any suggestion as to where it could live? Note we have
|
If we don't want to have it in |
I think eventually it should go in the We could maybe create an example in the top-level But I'm happy with any names that you guys are. Agree that |
Inspired me to open #1386 |
Drats, that is where all this started, I had moved it there and then second guessed myself. |
Another idea I had was to move the code into
And then move the whole thing to |
Nah, I think it's fine to just move the license blurb to a comment on the We could also ask Pieter (who authored the original code in 4bedfa9223d3 bitcoin/bitcoin#1795 commit 14/17) to relicense it if we want to be totally sure of things. |
Woops, some how I missed this comment this morning. With the license clarification from @apoelstra and this comment I'll re-spin the PR, thanks. |
In preparation for moving `MerkleBlock` into the `merkle_tree` module; create a new directory for the module and move `merkle_tree.rs` to `merkle_tree/mod.rs`.
Move the `merkleblock` module into the `merkle_tree` module in a submodule called `block`. In order to do the minimum amount of changes in this patch DO NOT rename types to improved naming and reduce stutter. Note: - block module is private - the three types are re-exported from `merkle_block` This patch purposefully does the minimum amount of changes because there a whole bunch of improvements to the old "merkleblock" module that are coming next.
6ff9d47
to
6131072
Compare
merkleblock
into merkle_tree
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.
ACK 6131072
Will be happy to re-review if the path changes to relative.
@@ -53,7 +53,7 @@ use crate::blockdata::block::{self, Block}; | |||
use crate::blockdata::transaction::Transaction; | |||
use crate::blockdata::constants::{MAX_BLOCK_WEIGHT, MIN_TRANSACTION_WEIGHT}; | |||
use crate::consensus::encode::{self, Decodable, Encodable}; | |||
use crate::util::merkleblock::MerkleBlockError::*; | |||
use crate::merkle_tree::MerkleBlockError::*; |
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.
WTF, this should've been self
.
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.
Hah! the number of times I changed this to self in the last few weeks. Eventually I tried to make the diff as unsurprising with minimal changes as possible.
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.
My rule of thumb is to never use absolute path that starts with the equivalent of self
. If this was self
from the beginning this diff line wouldn't be here now.
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.
Cool, I'll make that my own policy as well, cheers.
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.
ACK 6131072
861fdd6 Put the `MerkleBlock` struct at the top of the file (Tobin C. Harding) f0d9681 Put error at the bottom of the file (Tobin C. Harding) 19e0947 Use self for Error variant imports (Tobin C. Harding) 83c2a55 Put helper function below where its called (Tobin C. Harding) 5076579 Fix indentation in pmt_tests macro (Tobin C. Harding) a7edbfb Move hex data to tests/data (Tobin C. Harding) Pull request description: PR 2 in the `merkle_tree::block` series, used to be on top of the now merged #1374. Do a bunch of refactorings in preparation for more invasive changes. This is a separate PR because, other than the first patch which moves hex strings to `tests/data/` the other patches are refactoring only patches, no logic changes. However the last patch is big and will be annoying to review - sorry about that. If you really oppose this basically stylistic patch putting important things first, the opposite of C code, please say and I'll try to stop doing it. ACKs for top commit: Kixunil: ACK 861fdd6 apoelstra: ACK 861fdd6 Tree-SHA512: 3da0a600898f490b602ab05a396061587d86ffef55697877885a8c611eff96e7382a2d816fe9594c100d378dc56fe7fdc88009a0343bc602b7f4c180836adbd3
Re-done after review comments below. This is now PR 1 in the
merkle_tree::block
series :)Move the
merkleblock
module into themerkle_tree
module in a submodule calledblock
. In order to do the minimum amount of changes in this patch DO NOT rename types to improved naming and reduce stutter.Note:
merkle_block
MerkleBlock
re-export from the crate root is left in place.This patch purposefully does the minimum amount of changes because there a whole bunch of improvements to the old "merkleblock" module that are coming next in a separate PR.