Skip to content

Commit

Permalink
Remove dead code (finalizer lambda).
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jun 16, 2024
1 parent 08825f2 commit b1b8df0
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 145 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ include_bitcoin_database_locks_HEADERS = \
include_bitcoin_database_memorydir = ${includedir}/bitcoin/database/memory
include_bitcoin_database_memory_HEADERS = \
include/bitcoin/database/memory/accessor.hpp \
include/bitcoin/database/memory/finalizer.hpp \
include/bitcoin/database/memory/map.hpp \
include/bitcoin/database/memory/memory.hpp \
include/bitcoin/database/memory/reader.hpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\locks\interprocess_lock.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\locks\locks.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\accessor.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\finalizer.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\interfaces\memory.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\interfaces\storage.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\map.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\accessor.hpp">
<Filter>include\bitcoin\database\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\finalizer.hpp">
<Filter>include\bitcoin\database\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\memory\interfaces\memory.hpp">
<Filter>include\bitcoin\database\memory\interfaces</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion include/bitcoin/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <bitcoin/database/locks/interprocess_lock.hpp>
#include <bitcoin/database/locks/locks.hpp>
#include <bitcoin/database/memory/accessor.hpp>
#include <bitcoin/database/memory/finalizer.hpp>
#include <bitcoin/database/memory/map.hpp>
#include <bitcoin/database/memory/memory.hpp>
#include <bitcoin/database/memory/reader.hpp>
Expand Down
39 changes: 13 additions & 26 deletions include/bitcoin/database/impl/primitives/hashmap.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ bool CLASS::set(const Link& link, const Element& element) NOEXCEPT
return false;

iostream stream{ *ptr };
finalizer sink{ stream };
flipper sink{ stream };
sink.skip_bytes(index_size);

// (1.65%)
Expand Down Expand Up @@ -263,18 +263,17 @@ bool CLASS::put_link(Link& link, const Key& key,
return false;

iostream stream{ *ptr };
finalizer sink{ stream };
flipper sink{ stream };
sink.skip_bytes(Link::size);
sink.write_bytes(key);
sink.set_finalizer([this, link, index = head_.index(key), ptr]() NOEXCEPT
{
auto& next = unsafe_array_cast<uint8_t, Link::size>(ptr->begin());
return head_.push(link, next, index);
});

// (1.63%)
if constexpr (!is_slab) { BC_DEBUG_ONLY(sink.set_limit(Size * count);) }
return element.to_data(sink) && sink.finalize();
if (!element.to_data(sink))
return false;

auto& next = unsafe_array_cast<uint8_t, Link::size>(ptr->begin());
return head_.push(link, next, head_.index(key));
}

TEMPLATE
Expand All @@ -296,19 +295,16 @@ bool CLASS::put(const Link& link, const Key& key,
return false;

iostream stream{ *ptr };
finalizer sink{ stream };
flipper sink{ stream };
sink.skip_bytes(Link::size);
sink.write_bytes(key);

// The finalizer provides deferred index commit following serialization.
sink.set_finalizer([this, link, index = head_.index(key), ptr]() NOEXCEPT
{
auto& next = unsafe_array_cast<uint8_t, Link::size>(ptr->begin());
return head_.push(link, next, index);
});

if constexpr (!is_slab) { BC_DEBUG_ONLY(sink.set_limit(Size * count);) }
return element.to_data(sink) && sink.finalize();
if (!element.to_data(sink))
return false;

auto& next = unsafe_array_cast<uint8_t, Link::size>(ptr->begin());
return head_.push(link, next, head_.index(key));
}

TEMPLATE
Expand All @@ -327,15 +323,6 @@ bool CLASS::commit(const Link& link, const Key& key) NOEXCEPT
return head_.push(link, next, head_.index(key));
}

TEMPLATE
Link CLASS::commit_link(const Link& link, const Key& key) NOEXCEPT
{
if (!commit(link, key))
return {};

return link;
}

// protected/static
// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/impl/query/archive.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT
for (const auto& spend: views_reverse(spends))
{
--spend_fk.value;
if (store_.spend.commit_link(spend_fk, spend).is_terminal())
if (!store_.spend.commit(spend_fk, spend))
return error::tx_spend_commit;
}

Expand Down
78 changes: 0 additions & 78 deletions include/bitcoin/database/memory/finalizer.hpp

This file was deleted.

1 change: 0 additions & 1 deletion include/bitcoin/database/memory/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define LIBBITCOIN_DATABASE_MEMORY_MEMORY_HPP

#include <bitcoin/database/memory/accessor.hpp>
#include <bitcoin/database/memory/finalizer.hpp>
#include <bitcoin/database/memory/interfaces/memory.hpp>
#include <bitcoin/database/memory/interfaces/storage.hpp>
#include <bitcoin/database/memory/map.hpp>
Expand Down
3 changes: 1 addition & 2 deletions include/bitcoin/database/primitives/hashmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace libbitcoin {
namespace database {

/// Caution: iterator/reader/finalizer hold body remap lock until disposed.
/// Caution: iterator/reader/flipper hold body remap lock until disposed.
/// These handles should be used for serialization and immediately disposed.
/// Readers and writers are always prepositioned at data, and are limited to
/// the extent the record/slab size is known (limit can always be removed).
Expand Down Expand Up @@ -146,7 +146,6 @@ class hashmap

/// Commit previously set element at link to key.
bool commit(const Link& link, const Key& key) NOEXCEPT;
Link commit_link(const Link& link, const Key& key) NOEXCEPT;

protected:
/// Get element at link using memory object, false if deserialize error.
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/database/tables/archives/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct header
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
context::to_data(sink, ctx);
sink.write_byte(to_int<uint8_t>(milestone));
Expand Down Expand Up @@ -94,7 +94,7 @@ struct header
: public schema::header
{
// header->previous_block_hash() ignored.
inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
BC_ASSERT(header);
context::to_data(sink, ctx);
Expand All @@ -120,7 +120,7 @@ struct header
: public schema::header
{
// header.previous_block_hash() ignored.
inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
context::to_data(sink, ctx);
sink.write_byte(to_int<uint8_t>(milestone));
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/archives/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct point
return source;
}

inline bool to_data(const finalizer& sink) const NOEXCEPT
inline bool to_data(const flipper& sink) const NOEXCEPT
{
return sink;
}
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/archives/spend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct spend
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
sink.write_little_endian<uint32_t>(sequence);
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/archives/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct transaction
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_byte(to_int<uint8_t>(coinbase));
sink.write_little_endian<bytes::integer, bytes::size>(light);
Expand Down Expand Up @@ -139,7 +139,7 @@ struct transaction
struct record_put_ref
: public schema::transaction
{
inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
using namespace system;
sink.write_byte(to_int<uint8_t>(tx.is_coinbase()));
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/archives/txs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct txs
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
BC_ASSERT(tx_fks.size() < system::power2<uint64_t>(to_bits(schema::count_)));
const auto fks = system::possible_narrow_cast<tx::integer>(tx_fks.size());
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/caches/validated_bk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct validated_bk
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_little_endian<coding::integer, coding::size>(code);
sink.write_variable(fees);
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/caches/validated_tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct validated_tx
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
context::to_data(sink, ctx);
sink.write_little_endian<coding::integer, coding::size>(code);
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct context
context.mtp = source.template read_little_endian<uint32_t>();
};

static inline void to_data(finalizer& sink, const context& context) NOEXCEPT
static inline void to_data(flipper& sink, const context& context) NOEXCEPT
{
sink.template write_little_endian<flag::integer, flag::size>(context.flags);
sink.template write_little_endian<block::integer, block::size>(context.height);
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/indexes/strong_tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct strong_tx
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_little_endian<block::integer, block::size>(header_fk);
sink.write_byte(to_int<uint8_t>(positive));
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/optionals/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct address
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_little_endian<out::integer, out::size>(output_fk);
return sink;
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/database/tables/optionals/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//// return source;
//// }
////
//// inline bool to_data(finalizer& sink) const NOEXCEPT
//// inline bool to_data(flipper& sink) const NOEXCEPT
//// {
//// tx.to_data(sink, true);
//// BC_ASSERT(sink.get_write_position() == count());
Expand Down Expand Up @@ -81,7 +81,7 @@
//// return source;
//// }
////
//// inline bool to_data(finalizer& sink) const NOEXCEPT
//// inline bool to_data(flipper& sink) const NOEXCEPT
//// {
//// BC_ASSERT(tx);
//// tx->to_data(sink, true);
Expand All @@ -100,7 +100,7 @@
//// tx.serialized_size(true));
//// }
////
//// inline bool to_data(finalizer& sink) const NOEXCEPT
//// inline bool to_data(flipper& sink) const NOEXCEPT
//// {
//// tx.to_data(sink, true);
//// return sink;
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/optionals/neutrino.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct neutrino
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_bytes(filter_head);
sink.write_variable(filter.size());
Expand Down Expand Up @@ -117,7 +117,7 @@ struct neutrino
filter.size());
}

inline bool to_data(finalizer& sink) const NOEXCEPT
inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_bytes(filter_head);
sink.write_variable(filter.size());
Expand Down
Loading

0 comments on commit b1b8df0

Please sign in to comment.