Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove retainer, add block allocation metadata. #1516

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ include_bitcoin_system_HEADERS = \
include/bitcoin/system/have.hpp \
include/bitcoin/system/literals.hpp \
include/bitcoin/system/preprocessor.hpp \
include/bitcoin/system/retainer.hpp \
include/bitcoin/system/settings.hpp \
include/bitcoin/system/typelets.hpp \
include/bitcoin/system/types.hpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\system\radix\base_64.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\radix\base_85.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\radix\radix.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\retainer.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\serial\deserialize.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\serial\props.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\serial\serial.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\system\radix\radix.hpp">
<Filter>include\bitcoin\system\radix</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\system\retainer.hpp">
<Filter>include\bitcoin\system</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\system\serial\deserialize.hpp">
<Filter>include\bitcoin\system\serial</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion include/bitcoin/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <bitcoin/system/have.hpp>
#include <bitcoin/system/literals.hpp>
#include <bitcoin/system/preprocessor.hpp>
#include <bitcoin/system/retainer.hpp>
#include <bitcoin/system/settings.hpp>
#include <bitcoin/system/typelets.hpp>
#include <bitcoin/system/types.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <bitcoin/system/retainer.hpp>
#include <bitcoin/system/arena.hpp>

namespace libbitcoin {

Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/system/chain/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class BC_API block
/// Reference used to avoid copy, sets cache if not set (not thread safe).
const hash_digest& get_hash() const NOEXCEPT;

/// Set/get memory retainer.
void set_retainer(retainer::ptr&& retainer) const NOEXCEPT;
const retainer::ptr& get_retainer() const NOEXCEPT;
/// Set/get memory allocation.
void set_allocation(size_t allocation) const NOEXCEPT;
const size_t get_allocation() const NOEXCEPT;

/// Identity.
/// -----------------------------------------------------------------------
Expand Down Expand Up @@ -220,7 +220,7 @@ class BC_API block
// Cache.
bool valid_;
sizes size_;
mutable retainer::ptr retainer_{};
mutable size_t allocation_{};
};

typedef std_vector<block> blocks;
Expand Down
63 changes: 0 additions & 63 deletions include/bitcoin/system/retainer.hpp

This file was deleted.

12 changes: 4 additions & 8 deletions src/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,14 @@ void block::assign_data(reader& source, bool witness) NOEXCEPT
valid_ = source;
}

// Retainer will be an empty pointer when default allocator is used.
// Retainer release informs allocator that associated memory may be freed.
// Retainer is copied on block copy/assign, since allocations are thus shared.
// WARNING: retainer does not track objects shared from the block (e.g. tx).
void block::set_retainer(retainer::ptr&& retainer) const NOEXCEPT
void block::set_allocation(size_t allocation) const NOEXCEPT
{
retainer_ = std::move(retainer);
allocation_ = allocation;
}

const retainer::ptr& block::get_retainer() const NOEXCEPT
const size_t block::get_allocation() const NOEXCEPT
{
return retainer_;
return allocation_;
}

// Serialization.
Expand Down
3 changes: 1 addition & 2 deletions src/define.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
// boost : warnings
// exceptions : boost
// arena : exceptions
// retainer : arena
// allocator : retainer
// allocator : arena
// types : allocator
// constants : types
// literals : constants
Expand Down
Loading