Closed smee closed 6 years ago
Hi @harrigan,
the main idea imho would be to use the header
code: We have a payload with a prefix, so we need a way to parse the prefix (payload length and checksum) and use this information to parse the body (payload). Please refer to the example in the last commit.
Does this work for you?
Thank you @smee! That is exactly what I was trying to do.
Great. Since there is also a relevant bugfix to the padding
codec make sure to use the new release 0.5.2
Hi,
I'm extending your Bitcoin protocol example (demo/bitcoin.clj) to handle Bitcoin messages that are sent over the wire. The format is:
The problem I have run into is the checksum field between the length and the payload. I tried using something like:
(def payload (binary/blob :prefix length-and-checksum))
and having length-and-checksum reify BinaryIO so that it ignores the checksum when reading and just returns the length. However, for writing, I don't have access to the payload from here so I can't compute the checksum. Also, I'd prefer to compute the checksum outside of the codec.
Do you know of any way of doing this? Sorry if I missed something obvious and thank you for creating smee/binary.
Regards, @harrigan