Skip to content

Commit

Permalink
Add block message deserialize override for custom allocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jul 28, 2024
1 parent 1161248 commit 8746bb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/bitcoin/network/messages/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ struct BCT_API block
static const uint32_t version_minimum;
static const uint32_t version_maximum;

static cptr deserialize(auto& memory, uint32_t version,
const system::data_chunk& data, bool witness=true) NOEXCEPT;
static cptr deserialize(uint32_t version, const system::data_chunk& data,
bool witness=true) NOEXCEPT;
static block deserialize(uint32_t version, system::reader& source,
Expand All @@ -51,7 +53,6 @@ struct BCT_API block
size_t size(uint32_t version, bool witness) const NOEXCEPT;

system::chain::block::cptr block_ptr;
////mutable size_t cached_size{};
};

} // namespace messages
Expand Down
7 changes: 7 additions & 0 deletions src/messages/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ typename block::cptr block::deserialize(uint32_t version,
const system::data_chunk& data, bool witness) NOEXCEPT
{
static memory memory{};
return deserialize(memory, version, data, witness);
}

// static
typename block::cptr block::deserialize(auto& memory, uint32_t version,
const system::data_chunk& data, bool witness) NOEXCEPT
{
system::istream source{ data };
system::byte_reader reader{ source, memory.get_arena() };

Expand Down

0 comments on commit 8746bb0

Please sign in to comment.