Skip to content
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

getblocks, headers, getheaders, tx, getdata, notfound #44

Merged
merged 16 commits into from
Oct 10, 2019
Merged

Conversation

dconnolly
Copy link
Contributor

No description provided.

@dconnolly
Copy link
Contributor Author

image

@hdevalence
Copy link
Contributor

@dconnolly I think that the crate selection issues should be resolved with changes included in #17

}

fn read_inv<R: Read>(&self, reader: R) -> Result<Message, Error> {
let hashes = self._read_generic_inventory_hash_vector(reader)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than just having a generic inv vector reader function, since we are duplicating the vector reading code with other messages too, maybe it would be cleaner to add a

fn read_list<T: ZcashDeserialize>(&mut self, max_preallocation: usize) -> Result<Vec<T>, SerializationError>

to the ReadZcashExt trait that takes a bound on the number of items to preallocate, and use it in all of the message deserialization implementations?

We could also add a corresponding writer function but I'm not sure that it's as necessary because the encoding doesn't require validation logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm ok, I'll pursue this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll also need the bespoke encoded_<T>_size too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if max_preallocation is the number of items rather than the size of the allocation in bytes or something, then I think that the ENCODED_<T>_SIZE constants can live at each callsite, and they can compute self.builder.max_message_size / ENCODED_<T>_SIZE or something to get the number of items, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future I think it would be good to have size hint methods included in the ZcashSerialize trait but I'm not sure we need them immediately

@dconnolly dconnolly force-pushed the get-blocks branch 2 times, most recently from 9e59b04 to c974e74 Compare October 8, 2019 22:22
@dconnolly dconnolly marked this pull request as ready for review October 9, 2019 03:29
@dconnolly dconnolly changed the title getblocks, headers, getheaders, tx getblocks, headers, getheaders, tx, 'getdata', 'notfound' Oct 9, 2019
@dconnolly dconnolly changed the title getblocks, headers, getheaders, tx, 'getdata', 'notfound' getblocks, headers, getheaders, tx, getdata, notfound Oct 9, 2019
@hdevalence hdevalence mentioned this pull request Oct 9, 2019
19 tasks
@hdevalence
Copy link
Contributor

Does this add corresponding serialization implementations for these messages? I don't see them in Codec::write_body.

@dconnolly
Copy link
Contributor Author

Does this add corresponding serialization implementations for these messages? I don't see them in Codec::write_body.

Bah you are right, I knew I was missing something last night but couldn't remember. Will add before merge.

@dconnolly dconnolly requested a review from hdevalence October 10, 2019 02:02
@dconnolly
Copy link
Contributor Author

dconnolly commented Oct 10, 2019

After this is merged, we have some read/write stuff to do for Message::Reject, and need to do all of mempool, filterload, filteradd, filterclear, and merkleblock, and that's it I think.

@@ -138,27 +138,100 @@ pub enum Message {
///
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
Block {
/// Transaction data format version (note, this is signed).
version: Version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later: we may want to use an internal enum rather than carrying a version field around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this wasn't here for a long time because I think we had discussed handling Versions better.

// many results.
GetBlocks {
/// The protocol version.
version: Version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later: how does this version field interact with the versions of the blocks themselves?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, like, is this something we need to specify in the message itself, or can the codec fill it in? if the codec can't fill it in (<=> the version in the message is independent of the transport version), then how do version mismatches happen?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to be clear this could all be a new issue or go somewhere else, it's 'later' because it should be non-blocking for this PR)

Copy link
Contributor

@hdevalence hdevalence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants