Skip to content
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
8 changes: 4 additions & 4 deletions include/bitcoin/database/impl/memory/mmap_private.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ bool CLASS::resize_(size_t size) NOEXCEPT
const auto capacity = to_width<Column>(capacity_);

// Disk full detection, any other failure is an abort.
#if !defined (WITHOUT_FALLOCATE)
#if !defined(WITHOUT_FALLOCATE)
if (::fallocate(opened_[Column], 0, capacity, target - capacity) == fail)
#else
if (::ftruncate(opened_[Column], target) == fail)
Expand All @@ -279,7 +279,7 @@ bool CLASS::resize_(size_t size) NOEXCEPT
TEMPLATE
template <size_t Column>
bool CLASS::finalize_(size_t
#if !defined (WITHOUT_MADVISE) && !defined(HAVE_MSC)
#if !defined(HAVE_MSC) && !defined(WITHOUT_MADVISE)
size
#endif
) NOEXCEPT
Expand All @@ -294,7 +294,7 @@ bool CLASS::finalize_(size_t
return false;
}

#if !defined (WITHOUT_MADVISE) && !defined(HAVE_MSC)
#if !defined(HAVE_MSC) && !defined(WITHOUT_MADVISE)
// Get page size (usually 4KB).
const int page_size = ::sysconf(_SC_PAGESIZE);
const auto page = system::possible_narrow_sign_cast<size_t>(page_size);
Expand Down Expand Up @@ -330,7 +330,7 @@ bool CLASS::finalize_(size_t
return false;
}
}
#endif // !WITHOUT_MADVISE && !HAVE_MSC
#endif // !HAVE_MSC && !WITHOUT_MADVISE

loaded_ = true;
return true;
Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/database/impl/query/batch/ecdsa.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ bool CLASS::set_signatures(const hash_digest& digest,

// Write values to each column in corresponding positions.
return
store_.ecdsa.correlate.put(fk, correlate_t{ {}, link, ckeys, csigs, id }) &&
store_.ecdsa.digest.put(fk, digest_t{ {}, ckeys, csigs, digest }) &&
store_.ecdsa.compressed.put(fk, compressed_t{ {}, keys, csigs }) &&
store_.ecdsa.signature.put(fk, signature_t{ {}, ckeys, sigs });
store_.ecdsa.correlate.put(fk, correlate_t{ {}, count, link, ckeys, csigs, id }) &&
store_.ecdsa.digest.put(fk, digest_t{ {}, count, digest }) &&
store_.ecdsa.compressed.put(fk, compressed_t{ {}, count, keys, csigs }) &&
store_.ecdsa.signature.put(fk, signature_t{ {}, count, ckeys, sigs });
// ========================================================================
}

Expand Down
22 changes: 12 additions & 10 deletions include/bitcoin/database/impl/store/store.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ CLASS::store(const settings& config) NOEXCEPT
header_head_(head(config.path / schema::dir::heads, schema::archive::header), 1, 0, random),
header_body_(body(config.path, schema::archive::header), config.header_size, config.header_rate, sequential),

input_head_(head(config.path / schema::dir::heads, schema::archive::input), 1, 0, random),
input_head_(head(config.path / schema::dir::heads, schema::archive::input), 1, 0, sequential),
input_body_(body(config.path, schema::archive::input), config.input_size, config.input_rate, sequential),

output_head_(head(config.path / schema::dir::heads, schema::archive::output), 1, 0, random),
output_head_(head(config.path / schema::dir::heads, schema::archive::output), 1, 0, sequential),
output_body_(body(config.path, schema::archive::output), config.output_size, config.output_rate, sequential),

point_head_(head(config.path / schema::dir::heads, schema::archive::point), 1, 0, random),
point_body_(body(config.path, schema::archive::point), config.point_size, config.point_rate, sequential),

ins_head_(head(config.path / schema::dir::heads, schema::archive::ins), 1, 0, random),
ins_head_(head(config.path / schema::dir::heads, schema::archive::ins), 1, 0, sequential),
ins_body_(body(config.path, schema::archive::ins), config.ins_size, config.ins_rate, sequential),

outs_head_(head(config.path / schema::dir::heads, schema::archive::outs), 1, 0, random),
outs_head_(head(config.path / schema::dir::heads, schema::archive::outs), 1, 0, sequential),
outs_body_(body(config.path, schema::archive::outs), config.outs_size, config.outs_rate, sequential),

tx_head_(head(config.path / schema::dir::heads, schema::archive::tx), 1, 0, random),
Expand All @@ -58,10 +58,10 @@ CLASS::store(const settings& config) NOEXCEPT
// Indexes.
// ------------------------------------------------------------------------

candidate_head_(head(config.path / schema::dir::heads, schema::indexes::candidate), 1, 0, random),
candidate_head_(head(config.path / schema::dir::heads, schema::indexes::candidate), 1, 0, sequential),
candidate_body_(body(config.path, schema::indexes::candidate), config.candidate_size, config.candidate_rate, sequential),

confirmed_head_(head(config.path / schema::dir::heads, schema::indexes::confirmed), 1, 0, random),
confirmed_head_(head(config.path / schema::dir::heads, schema::indexes::confirmed), 1, 0, sequential),
confirmed_body_(body(config.path, schema::indexes::confirmed), config.confirmed_size, config.confirmed_rate, sequential),

strong_tx_head_(head(config.path / schema::dir::heads, schema::indexes::strong_tx), 1, 0, random),
Expand All @@ -70,19 +70,21 @@ CLASS::store(const settings& config) NOEXCEPT
// Caches.
// ------------------------------------------------------------------------

ecdsa_head_(head(config.path / schema::dir::heads, schema::caches::ecdsa), 1, 0, random),
// TODO: body not random, but keep in memory.
ecdsa_head_(head(config.path / schema::dir::heads, schema::caches::ecdsa), 1, 0, sequential),
ecdsa_body_(body(config.path, schema::caches::ecdsa), config.ecdsa_size, config.ecdsa_rate, sequential),

schnorr_head_(head(config.path / schema::dir::heads, schema::caches::schnorr), 1, 0, random),
// TODO: body not random, but keep in memory.
schnorr_head_(head(config.path / schema::dir::heads, schema::caches::schnorr), 1, 0, sequential),
schnorr_body_(body(config.path, schema::caches::schnorr), config.schnorr_size, config.schnorr_rate, sequential),

silent_head_(head(config.path / schema::dir::heads, schema::caches::silent), 1, 0, random),
silent_head_(head(config.path / schema::dir::heads, schema::caches::silent), 1, 0, sequential),
silent_body_(body(config.path, schema::caches::silent), config.silent_size, config.silent_rate, sequential),

duplicate_head_(head(config.path / schema::dir::heads, schema::caches::duplicate), 1, 0, random),
duplicate_body_(body(config.path, schema::caches::duplicate), config.duplicate_size, config.duplicate_rate, sequential),

prevalid_head_(head(config.path / schema::dir::heads, schema::caches::prevalid), 1, 0, random),
prevalid_head_(head(config.path / schema::dir::heads, schema::caches::prevalid), 1, 0, sequential),
prevalid_body_(body(config.path, schema::caches::prevalid), config.prevalid_size, config.prevalid_rate, sequential),

prevout_head_(head(config.path / schema::dir::heads, schema::caches::prevout), 1, 0, random),
Expand Down
33 changes: 12 additions & 21 deletions include/bitcoin/database/tables/caches/ecdsa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,20 @@ struct ecdsa_digest
{
inline link count() const NOEXCEPT
{
using namespace system;
return possible_narrow_cast<link::integer>(
chain::multisig::rows(sigs, keys));
return system::possible_narrow_cast<link::integer>(rows);
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
// ecdsa multisig capture is limited to common signature hash.
for (size_t row{}; row < count(); ++row)
for (size_t row{}; row < rows; ++row)
sink.write_bytes(digest);

BC_ASSERT(!sink || sink.get_write_position() == count() * minrow);
return sink;
}

const size_t keys{};
const size_t sigs{};
const size_t rows{};
const hash_digest& digest;
};
};
Expand Down Expand Up @@ -107,18 +104,15 @@ struct ecdsa_compressed
{
inline link count() const NOEXCEPT
{
using namespace system;
return possible_narrow_cast<link::integer>(
chain::multisig::rows(sigs, keys.size()));
return system::possible_narrow_cast<link::integer>(rows);
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
using namespace system::chain;
const auto m = sigs;
const auto n = keys.size();
if (!multisig::check(m, n))
return false;
BC_ASSERT(multisig::rows(m, n) == rows);

const auto gap = (n - m);
for (size_t sig{}; sig < m; ++sig)
Expand All @@ -129,6 +123,7 @@ struct ecdsa_compressed
return sink;
}

const size_t rows{};
const std::span<const system::ec_compressed> keys;
const size_t sigs{};
};
Expand Down Expand Up @@ -163,18 +158,15 @@ struct ecdsa_signature
{
inline link count() const NOEXCEPT
{
using namespace system;
return possible_narrow_cast<link::integer>(
chain::multisig::rows(sigs.size(), keys));
return system::possible_narrow_cast<link::integer>(rows);
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
using namespace system::chain;
const auto m = sigs.size();
const auto n = keys;
if (!multisig::check(m, n))
return false;
BC_ASSERT(multisig::rows(m, n) == rows);

const auto gap = (n - m);
for (size_t sig{}; sig < m; ++sig)
Expand All @@ -185,6 +177,7 @@ struct ecdsa_signature
return sink;
}

const size_t rows{};
const size_t keys{};
const std::span<const system::ec_signature> sigs;
};
Expand Down Expand Up @@ -247,18 +240,15 @@ struct ecdsa_correlate
{
inline link count() const NOEXCEPT
{
using namespace system;
return possible_narrow_cast<link::integer>(
chain::multisig::rows(sigs, keys));
return system::possible_narrow_cast<link::integer>(rows);
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
using namespace system::chain;
const auto m = sigs;
const auto n = keys;
if (!multisig::check(m, n))
return false;
BC_ASSERT(multisig::rows(m, n) == rows);

const auto gap = (n - m);
for (size_t sig{}; sig < m; ++sig)
Expand All @@ -275,6 +265,7 @@ struct ecdsa_correlate
return sink;
}

const size_t rows{};
const hd::integer header_fk{};
const size_t keys{};
const size_t sigs{};
Expand Down
8 changes: 4 additions & 4 deletions test/tables/caches/ecdsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(ecdsa_correlate__put_refs__one_of_three__expected)
);

// put_refs{ {}, header_fk, keys, sigs, group }.
BOOST_REQUIRE(instance.put(putter{ {}, header_fk, 3_size, 1_size, group }));
BOOST_REQUIRE(instance.put(putter{ {}, 3_size, header_fk, 3_size, 1_size, group }));
BOOST_REQUIRE_EQUAL(body_store.buffer(), expected);
}

Expand Down Expand Up @@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE(ecdsa_digest__put_refs__repeated__expected)
);

// put_refs{ {}, keys, sigs, digest }.
BOOST_REQUIRE(instance.put(putter{ {}, 3_size, 1_size, digest_a }));
BOOST_REQUIRE(instance.put(putter{ {}, 3_size, digest_a }));
BOOST_REQUIRE_EQUAL(body_store.buffer(), expected);
}

Expand Down Expand Up @@ -272,7 +272,7 @@ BOOST_AUTO_TEST_CASE(ecdsa_compressed__put_refs__matrix__expected)
);

// put_refs{ {}, keys, sigs }.
BOOST_REQUIRE(instance.put(putter{ {}, keys, 1_size }));
BOOST_REQUIRE(instance.put(putter{ {}, 3_size, keys, 1_size }));
BOOST_REQUIRE_EQUAL(body_store.buffer(), expected);
}

Expand Down Expand Up @@ -322,7 +322,7 @@ BOOST_AUTO_TEST_CASE(ecdsa_signature__put_refs__repeated__expected)
);

// put_refs{ {}, keys, sigs }.
BOOST_REQUIRE(instance.put(putter{ {}, 3_size, signatures }));
BOOST_REQUIRE(instance.put(putter{ {}, 3_size, 3_size, signatures }));
BOOST_REQUIRE_EQUAL(body_store.buffer(), expected);
}

Expand Down
Loading
Loading