The block constructor now just initializes block with default values. We provide explicit methods
for building block from a buffer ( data is there, on the buffer ), or from a file ( lazy, does not retrieve block data );
Make the buffer a private member.
Simplify method for getting corrupted/uncorrupted blocks from a list of blocks
fetchBlockData() renamed to fetch(), also, fetch() sets the corrupted flag in any case whether the size does not correspond with the block size.
Fixed a mistake where the last block had the receipt block_size, even if it was smaller due to being the last block.
Now the size value is correctly set for the last of the blocks.
Remove mistaken code.
A block cannot be fetched without providing a buffer. This is obvious for performance reasons, you do not want each block to allocate its own buffer, instead re-use an existing one ( think really large files ).
Thus it makes sense that the fetch() function requires the buffer to be passed by parameter. We also prevent repetitive code setting up the buffer manually before each fetch() call.
Couple of leaks fixed.