RCasatta/blocks_iterator

`BlockExtra` version 1 binary format

RCasatta opened this issue · 0 comments

At the moment BlockExtra contains a bitcoin::Block

pub block: Block,

There are cases when you are interested only in a small fraction of the block and paying the cost of allocating all the block objects could impact performance. In other words, the cases where bitcoin_slices make sense.

What could help would be a BlockExtra version with Vec<u8> instead of a Block so that the downstream user could avoid instantiating a Block and use a bitcoin_slices::Visitor instead.

We have the byte size of the Block in BlockExtra, however in the binary format it appears after the block data, thus we cannot "skip" block parsing that is variable lenght.

Binary format version 1 could instead write the size before the Block so that if the user require the faster version could simply allocate a single Vec<u8> for the block .

steps:

  • release a 1.x version where version greater than 1 errors
  • make the PR, change the binary format and change crate version to 2.x, this version could decode both version 0 and 1, and encode the 2 versions according to a parameter, use version 0 by default so that version upgrade is opt-in