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
17 changes: 7 additions & 10 deletions include/bitcoin/database/impl/query/signatures.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,21 @@ bool CLASS::set_signature(const hash_digest& digest, const ec_compressed& point,
}

TEMPLATE
bool CLASS::set_signatures(const hash_digest& ,
const multisig_views& , uint16_t , const header_link& ) NOEXCEPT
bool CLASS::set_signatures(const hash_digest& , const ec_compresseds& ,
const ec_signatures& , uint16_t , const header_link& ) NOEXCEPT
{
// ========================================================================
const auto scope = store_.get_transactor();

// TODO: allocate and then iterate.

// Clean single allocation failure (e.g. disk full).
////return store_.multisig.put(table::multisig::record
////return store_.multisig.put(table::multisig::put_ref
////{
//// {},
//// digest,
//// point,
//// signature,
//// pair,
//// link,
//// set
//// keys,
//// sigs,
//// set,
//// link
////});
// ========================================================================

Expand Down
6 changes: 4 additions & 2 deletions include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class query
using chain_state = system::chain::chain_state;
using chain_state_cptr = system::chain::chain_state::cptr;
using chain_context = system::chain::context;
using ec_compresseds = system::ec_compresseds;
using ec_compressed = system::ec_compressed;
using ec_signatures = system::ec_signatures;
using ec_signature = system::ec_signature;
using ec_xonly = system::ec_xonly;

Expand Down Expand Up @@ -575,8 +577,8 @@ class query
const ec_signature& signature, const header_link& link) NOEXCEPT;
bool set_signature(const hash_digest& digest, const ec_compressed& point,
const ec_signature& signature, const header_link& link) NOEXCEPT;
bool set_signatures(const hash_digest& digest, const multisig_views& pairs,
uint16_t set, const header_link& link) NOEXCEPT;
bool set_signatures(const hash_digest& digest, const ec_compresseds& keys,
const ec_signatures& sigs, uint16_t set, const header_link& link) NOEXCEPT;

/// Confirmation.
/// -----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/caches/ecdsa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct ecdsa
};
};

static_assert(sizeof(system::ecdsa::triple) == schema::ecdsa::minrow);
static_assert(sizeof(system::ecdsa::batch) == schema::ecdsa::minrow);

} // namespace table
} // namespace database
Expand Down
51 changes: 50 additions & 1 deletion include/bitcoin/database/tables/caches/multisig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,58 @@ struct multisig
uint16_t set{};
header::integer header_fk{};
};

struct put_ref
: public schema::multisig
{
inline link count() const NOEXCEPT
{
using namespace system;
const auto m = sigs.size();
const auto n = keys.size();

BC_ASSERT(!is_subtract_overflow(n, m));
BC_ASSERT(!is_add_overflow(n - m, one));
BC_ASSERT(!is_multiply_overflow(m, add1(n - m)));
return possible_narrow_cast<link::integer>(m * add1(n - m));
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
using namespace system;
const auto m = sigs.size();
const auto n = keys.size();
constexpr auto max = power2(to_half(byte_bits));
if (is_zero(m) || is_zero(n) || n > max || m > n)
return false;

for (size_t sig{}; sig < m; ++sig)
{
for (auto key = sig; key <= n - (m - sig); ++key)
{
sink.write_bytes(digest);
sink.write_bytes(keys.at(key));
sink.write_bytes(sigs.at(sig));
sink.write_byte(pack_word<uint8_t>(m, n));
sink.write_little_endian<uint16_t>(set);
sink.write_little_endian<header::integer, header::size>(
header_fk);
}
}

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

const hash_digest& digest;
const system::ec_compresseds& keys;
const system::ec_signatures& sigs;
const uint16_t set{};
const header::integer header_fk{};
};
};

static_assert(sizeof(system::multisig::triple) == schema::multisig::minrow);
static_assert(sizeof(system::multisig::batch) == schema::multisig::minrow);

} // namespace table
} // namespace database
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/caches/schnorr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct schnorr
};
};

static_assert(sizeof(system::schnorr::triple) == schema::schnorr::minrow);
static_assert(sizeof(system::schnorr::batch) == schema::schnorr::minrow);

} // namespace table
} // namespace database
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/database/tables/schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ struct multisig
system::hash_size +
system::ec_compressed_size +
system::ec_signature_size +
schema::header::pk +
count_ + // input (within block) correlation counter.
one; // [m|n] pairing merged to one byte (max 16).
one + // [m|n] pairing merged to one byte (max 16).
count_ + // input (within block) correlation counter.
schema::header::pk;
static constexpr size_t minrow = minsize;
static constexpr size_t size = minsize;
static constexpr link count() NOEXCEPT { return 1; }
Expand Down
Loading