diff --git a/Makefile.am b/Makefile.am
index af2c653a..d5b70288 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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 \
diff --git a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj
index 167b5e16..d9a7da4f 100644
--- a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj
+++ b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj
@@ -103,7 +103,6 @@
-
diff --git a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters
index b06e7795..b083dd04 100644
--- a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters
+++ b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters
@@ -152,9 +152,6 @@
include\bitcoin\database\memory
-
- include\bitcoin\database\memory
-
include\bitcoin\database\memory\interfaces
diff --git a/include/bitcoin/database.hpp b/include/bitcoin/database.hpp
index bc7542a3..4d72feb4 100644
--- a/include/bitcoin/database.hpp
+++ b/include/bitcoin/database.hpp
@@ -32,7 +32,6 @@
#include
#include
#include
-#include
#include
#include
#include
diff --git a/include/bitcoin/database/impl/primitives/hashmap.ipp b/include/bitcoin/database/impl/primitives/hashmap.ipp
index 056b551b..ef5faafa 100644
--- a/include/bitcoin/database/impl/primitives/hashmap.ipp
+++ b/include/bitcoin/database/impl/primitives/hashmap.ipp
@@ -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%)
@@ -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(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(ptr->begin());
+ return head_.push(link, next, head_.index(key));
}
TEMPLATE
@@ -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(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(ptr->begin());
+ return head_.push(link, next, head_.index(key));
}
TEMPLATE
@@ -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
// ----------------------------------------------------------------------------
diff --git a/include/bitcoin/database/impl/query/archive.ipp b/include/bitcoin/database/impl/query/archive.ipp
index 17000465..554f8bed 100644
--- a/include/bitcoin/database/impl/query/archive.ipp
+++ b/include/bitcoin/database/impl/query/archive.ipp
@@ -583,6 +583,7 @@ typename CLASS::transaction::cptr CLASS::get_transaction(
tx.locktime
);
+ // Witness hash is not retained by the store.
ptr->set_nominal_hash(std::move(tx.key));
return ptr;
}
@@ -798,7 +799,7 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT
return error::tx_spend_set;
}
- // Acumulate spends (input references) in order.
+ // Accumulate spends (input references) in order.
puts.spend_fks.push_back(spend_fk.value++);
}
@@ -817,7 +818,7 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT
return error::tx_output_put;
}
- // Acumulate outputs in order.
+ // Accumulate outputs in order.
puts.out_fks.push_back(output_fk);
}
@@ -850,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;
}
diff --git a/include/bitcoin/database/memory/finalizer.hpp b/include/bitcoin/database/memory/finalizer.hpp
deleted file mode 100644
index bcf0c774..00000000
--- a/include/bitcoin/database/memory/finalizer.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
- *
- * This file is part of libbitcoin.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-#ifndef LIBBITCOIN_DATABASE_MEMORY_FINALIZER_HPP
-#define LIBBITCOIN_DATABASE_MEMORY_FINALIZER_HPP
-
-#include
-#include
-#include
-#include
-#include
-
-namespace libbitcoin {
-namespace database {
-
-// This is single inheritance.
-BC_PUSH_WARNING(DIAMOND_INHERITANCE)
-
-/// A byte flipper with finalization extentions, that accepts an iostream.
-template
-class finalizer_
- : public system::byte_flipper
-{
-public:
- DEFAULT_COPY_MOVE_DESTRUCT(finalizer_);
-
- using finalization = std::function;
-
- finalizer_(IOStream& stream) NOEXCEPT
- : system::byte_flipper(stream)
- {
- }
-
- void set_finalizer(finalization&& functor) NOEXCEPT
- {
- finalize_ = std::move(functor);
- }
-
- // This is expected to have side effect on the stream buffer, specifically
- // setting the "next" pointer into beginning of the address space.
- bool finalize() NOEXCEPT
- {
- if (!*this) return false;
-
- // std::function does not allow for noexcept.
- BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
- return finalize_();
- BC_POP_WARNING()
- }
-
-private:
- finalization finalize_;
-};
-
-/// A finalizing byte reader/writer that copies data from/to a memory_ptr.
-using finalizer = finalizer_<>;
-
-BC_POP_WARNING()
-
-} // namespace database
-} // namespace libbitcoin
-
-#endif
diff --git a/include/bitcoin/database/memory/memory.hpp b/include/bitcoin/database/memory/memory.hpp
index 6752ec37..4f1d659f 100644
--- a/include/bitcoin/database/memory/memory.hpp
+++ b/include/bitcoin/database/memory/memory.hpp
@@ -20,7 +20,6 @@
#define LIBBITCOIN_DATABASE_MEMORY_MEMORY_HPP
#include
-#include
#include
#include
#include
diff --git a/include/bitcoin/database/primitives/hashmap.hpp b/include/bitcoin/database/primitives/hashmap.hpp
index 679bc2be..d266271e 100644
--- a/include/bitcoin/database/primitives/hashmap.hpp
+++ b/include/bitcoin/database/primitives/hashmap.hpp
@@ -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).
@@ -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.
diff --git a/include/bitcoin/database/tables/archives/header.hpp b/include/bitcoin/database/tables/archives/header.hpp
index 45e0c0fa..73d62960 100644
--- a/include/bitcoin/database/tables/archives/header.hpp
+++ b/include/bitcoin/database/tables/archives/header.hpp
@@ -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(milestone));
@@ -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);
@@ -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(milestone));
diff --git a/include/bitcoin/database/tables/archives/point.hpp b/include/bitcoin/database/tables/archives/point.hpp
index a6845170..f68159f2 100644
--- a/include/bitcoin/database/tables/archives/point.hpp
+++ b/include/bitcoin/database/tables/archives/point.hpp
@@ -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;
}
diff --git a/include/bitcoin/database/tables/archives/spend.hpp b/include/bitcoin/database/tables/archives/spend.hpp
index bd7ea9a4..b79cb1b9 100644
--- a/include/bitcoin/database/tables/archives/spend.hpp
+++ b/include/bitcoin/database/tables/archives/spend.hpp
@@ -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(parent_fk);
sink.write_little_endian(sequence);
diff --git a/include/bitcoin/database/tables/archives/transaction.hpp b/include/bitcoin/database/tables/archives/transaction.hpp
index 26837376..c2e1cd86 100644
--- a/include/bitcoin/database/tables/archives/transaction.hpp
+++ b/include/bitcoin/database/tables/archives/transaction.hpp
@@ -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(coinbase));
sink.write_little_endian(light);
@@ -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(tx.is_coinbase()));
diff --git a/include/bitcoin/database/tables/archives/txs.hpp b/include/bitcoin/database/tables/archives/txs.hpp
index 6f0bca26..3233a228 100644
--- a/include/bitcoin/database/tables/archives/txs.hpp
+++ b/include/bitcoin/database/tables/archives/txs.hpp
@@ -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(to_bits(schema::count_)));
const auto fks = system::possible_narrow_cast(tx_fks.size());
diff --git a/include/bitcoin/database/tables/caches/validated_bk.hpp b/include/bitcoin/database/tables/caches/validated_bk.hpp
index b15fe1f9..2ad8264b 100644
--- a/include/bitcoin/database/tables/caches/validated_bk.hpp
+++ b/include/bitcoin/database/tables/caches/validated_bk.hpp
@@ -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(code);
sink.write_variable(fees);
diff --git a/include/bitcoin/database/tables/caches/validated_tx.hpp b/include/bitcoin/database/tables/caches/validated_tx.hpp
index 852e62ce..23098cff 100644
--- a/include/bitcoin/database/tables/caches/validated_tx.hpp
+++ b/include/bitcoin/database/tables/caches/validated_tx.hpp
@@ -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(code);
diff --git a/include/bitcoin/database/tables/context.hpp b/include/bitcoin/database/tables/context.hpp
index f6d043e3..e03873fc 100644
--- a/include/bitcoin/database/tables/context.hpp
+++ b/include/bitcoin/database/tables/context.hpp
@@ -41,7 +41,7 @@ struct context
context.mtp = source.template read_little_endian();
};
- 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(context.flags);
sink.template write_little_endian(context.height);
diff --git a/include/bitcoin/database/tables/indexes/strong_tx.hpp b/include/bitcoin/database/tables/indexes/strong_tx.hpp
index 4d5470db..6b3db6ce 100644
--- a/include/bitcoin/database/tables/indexes/strong_tx.hpp
+++ b/include/bitcoin/database/tables/indexes/strong_tx.hpp
@@ -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(header_fk);
sink.write_byte(to_int(positive));
diff --git a/include/bitcoin/database/tables/optionals/address.hpp b/include/bitcoin/database/tables/optionals/address.hpp
index dc243f85..9186eded 100644
--- a/include/bitcoin/database/tables/optionals/address.hpp
+++ b/include/bitcoin/database/tables/optionals/address.hpp
@@ -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(output_fk);
return sink;
diff --git a/include/bitcoin/database/tables/optionals/buffer.hpp b/include/bitcoin/database/tables/optionals/buffer.hpp
index 52c81e04..bb0fbbb8 100644
--- a/include/bitcoin/database/tables/optionals/buffer.hpp
+++ b/include/bitcoin/database/tables/optionals/buffer.hpp
@@ -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());
@@ -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);
@@ -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;
diff --git a/include/bitcoin/database/tables/optionals/neutrino.hpp b/include/bitcoin/database/tables/optionals/neutrino.hpp
index 9d617dfa..54b99de6 100644
--- a/include/bitcoin/database/tables/optionals/neutrino.hpp
+++ b/include/bitcoin/database/tables/optionals/neutrino.hpp
@@ -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());
@@ -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());
diff --git a/test/primitives/hashmap.cpp b/test/primitives/hashmap.cpp
index 1e870b62..4c4df623 100644
--- a/test/primitives/hashmap.cpp
+++ b/test/primitives/hashmap.cpp
@@ -29,7 +29,7 @@ class hashmap_
using base = hashmap;
using hashmap::hashmap;
////using reader_ptr = std::shared_ptr;
- ////using finalizer_ptr = std::shared_ptr;
+ ////using flipper_ptr = std::shared_ptr;
////
////reader_ptr getter_(const Key& key) const NOEXCEPT
////{
@@ -48,7 +48,7 @@ class hashmap_
//// return source;
////}
////
- ////finalizer_ptr creater_(const Key& key, const Link& size=bc::one) NOEXCEPT
+ ////flipper_ptr creater_(const Key& key, const Link& size=bc::one) NOEXCEPT
////{
//// using namespace system;
//// const auto link = allocate(size);
@@ -57,10 +57,10 @@ class hashmap_
//// return {};
////
//// iostream stream{ *ptr };
- //// const auto sink = std::make_shared(stream);
+ //// const auto sink = std::make_shared(stream);
//// sink->skip_bytes(Link::size);
//// sink->write_bytes(key);
- //// sink->set_finalizer([this, link, index = head_.index(key), ptr]() NOEXCEPT
+ //// sink->set_flipper([this, link, index = head_.index(key), ptr]() NOEXCEPT
//// {
//// auto& next = unsafe_array_cast(ptr->begin());
//// return head_.push(link, next, index);
@@ -432,7 +432,7 @@ class little_record
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_little_endian(value);
return sink;
@@ -453,7 +453,7 @@ class big_record
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_big_endian(value);
return sink;
@@ -560,7 +560,7 @@ class little_slab
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_little_endian(value);
return sink;
@@ -584,7 +584,7 @@ class big_slab
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_big_endian(value);
return sink;
@@ -649,7 +649,7 @@ class record_excess
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_big_endian(value);
return sink;
@@ -711,7 +711,7 @@ class slab_excess
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_big_endian(value);
return sink;
@@ -734,7 +734,7 @@ class file_excess
return source;
}
- bool to_data(database::finalizer& sink) const NOEXCEPT
+ bool to_data(database::flipper& sink) const NOEXCEPT
{
sink.write_big_endian(value);
return sink;
@@ -1217,7 +1217,7 @@ BOOST_AUTO_TEST_CASE(hashmap__allocate_put2__record__expected)
BOOST_REQUIRE(!instance.get_fault());
}
-BOOST_AUTO_TEST_CASE(hashmap__set_commit_link__slab__expected)
+BOOST_AUTO_TEST_CASE(hashmap__commit__slab__expected)
{
test::chunk_storage head_store{};
test::chunk_storage body_store{};
@@ -1234,7 +1234,7 @@ BOOST_AUTO_TEST_CASE(hashmap__set_commit_link__slab__expected)
BOOST_REQUIRE_EQUAL(body_store.buffer(), base16_chunk("00000000000000000000000000000004030201"));
constexpr key10 key1{ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a };
- BOOST_REQUIRE(!instance.commit_link(link, key1).is_terminal());
+ BOOST_REQUIRE(instance.commit(link, key1));
BOOST_REQUIRE_EQUAL(head_store.buffer(), base16_chunk("00000000000000000000ffffffffff"));
BOOST_REQUIRE_EQUAL(body_store.buffer(), base16_chunk("ffffffffff0102030405060708090a04030201"));
BOOST_REQUIRE(!instance.get_fault());