Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/messages/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,30 @@ typename block::cptr block::deserialize(uint32_t version,
header.set_hash(bitcoin_hash(header_size, data.data()));
auto begin = std::next(data.data(), header_size);

auto coinbase = true;
for (const auto& tx: *message->block_ptr->transactions_ptr())
{
// TODO: consider having tx cache serialized sizes.
const auto true_size = tx->serialized_size(true);
////tx->set_witness_hash(bitcoin_hash(true_size, begin));

// If segregated the hashes are distinct, cache both.
if (tx->is_segregated())
{
const auto end = std::next(begin, tx->serialized_size(false));
tx->set_hash(transaction::desegregated_hash({ begin, end }));
// Coinbase witness hash is null_hash, do not cache.
if (!coinbase)
{
const auto end = std::next(begin, tx->serialized_size(false));
tx->set_hash(transaction::desegregated_hash({ begin, end }));
}
}
else
{
// Avoiding witness hash caching for now.
tx->set_hash(bitcoin_hash(true_size, begin));
}

coinbase = false;
std::advance(begin, true_size);
}

Expand Down