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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ jobs:
- name: Coveralls Calculation
if: ${{ matrix.coverage == 'cov' }}
run: |
lcov --ignore-errors version,gcov,mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors version,gcov,mismatch,mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors unused --remove coverage.info "/usr/*" "${{ env.LIBBITCOIN_SRC_PATH }}prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info
lcov --list coverage.info

Expand Down Expand Up @@ -494,7 +494,7 @@ jobs:
- name: Coveralls Calculation
if: ${{ matrix.coverage == 'cov' }}
run: |
lcov --ignore-errors version,gcov,mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors version,gcov,mismatch,mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors unused --remove coverage.info "/usr/*" "${{ env.LIBBITCOIN_SRC_PATH }}prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info
lcov --list coverage.info

Expand Down Expand Up @@ -731,7 +731,7 @@ jobs:
- name: Coveralls Calculation
if: ${{ matrix.coverage == 'cov' }}
run: |
lcov --ignore-errors version,gcov,mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors version,gcov,mismatch,mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors unused --remove coverage.info "/usr/*" "${{ env.LIBBITCOIN_SRC_PATH }}prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info
lcov --list coverage.info

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/impl/query/archive_write.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ code CLASS::set_code(const block& block, const header_link& key,
if (is_zero(txs))
return error::txs_empty;

const auto count = possible_narrow_cast<tx_link::integer>(txs);
const auto count = possible_narrow_cast<unsigned_type<schema::count_>>(txs);
const auto tx_fks = store_.tx.allocate(count);
if (tx_fks.is_terminal())
return error::tx_tx_allocate;
Expand Down Expand Up @@ -417,9 +417,9 @@ code CLASS::set_code(const block& block, const header_link& key,
return store_.txs.put(to_txs(key), table::txs::put_group
{
{},
count,
light,
heavy,
count,
tx_fks,
std::move(interval),
depth
Expand Down
1 change: 0 additions & 1 deletion include/bitcoin/database/impl/query/validate.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ bool CLASS::set_tx_state(const tx_link& link, const context& ctx,
uint64_t fee, size_t sigops, schema::tx_state state) NOEXCEPT
{
using sigs = linkage<schema::sigops>;
BC_ASSERT(sigops<system::power2<sigs::integer>(to_bits(sigs::size)));

// ========================================================================
const auto scope = store_.get_transactor();
Expand Down
143 changes: 91 additions & 52 deletions include/bitcoin/database/tables/archives/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,61 @@ namespace table {
struct header
: public hash_map<schema::header>
{
using head = schema::header::link;
using hash_map<schema::header>::hashmap;
static constexpr auto offset = head::bits;
static_assert(offset < to_bits(head::size));

static constexpr size_t skip_to_height =
context::flag_t::size;

static constexpr size_t skip_to_mtp =
skip_to_height +
context::height_t::size;

static constexpr size_t skip_to_parent =
skip_to_mtp +
sizeof(uint32_t);

static constexpr size_t skip_to_version =
skip_to_parent +
link::size;

static constexpr size_t skip_to_timestamp =
skip_to_version +
sizeof(uint32_t);

static constexpr size_t skip_to_bits =
skip_to_timestamp +
sizeof(uint32_t);

static constexpr head::integer merge(bool milestone,
head::integer parent_fk) NOEXCEPT
{
using namespace system;
BC_ASSERT_MSG(!get_right(parent_fk, offset), "overflow");
return set_right(parent_fk, offset, milestone);
}

static constexpr bool is_milestone(link::integer merged) NOEXCEPT
{
return system::get_right(merged, offset);
}

static constexpr link::integer to_parent(link::integer merged) NOEXCEPT
{
return system::set_right(merged, offset, false);
}

struct record
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
context::from_data(source, ctx);
milestone = to_bool(source.read_byte());
parent_fk = source.read_little_endian<link::integer, link::size>();
const auto merged = source.read_little_endian<link::integer, link::size>();
milestone = is_milestone(merged);
parent_fk = to_parent(merged);
version = source.read_little_endian<uint32_t>();
timestamp = source.read_little_endian<uint32_t>();
bits = source.read_little_endian<uint32_t>();
Expand All @@ -55,8 +100,7 @@ struct header
inline bool to_data(finalizer& sink) const NOEXCEPT
{
context::to_data(sink, ctx);
sink.write_byte(to_int<uint8_t>(milestone));
sink.write_little_endian<link::integer, link::size>(parent_fk);
sink.write_little_endian<link::integer, link::size>(merge(milestone, parent_fk));
sink.write_little_endian<uint32_t>(version);
sink.write_little_endian<uint32_t>(timestamp);
sink.write_little_endian<uint32_t>(bits);
Expand Down Expand Up @@ -96,8 +140,7 @@ struct header
inline bool to_data(finalizer& sink) const NOEXCEPT
{
context::to_data(sink, ctx);
sink.write_byte(to_int<uint8_t>(milestone));
sink.write_little_endian<link::integer, link::size>(parent_fk);
sink.write_little_endian<link::integer, link::size>(merge(milestone, parent_fk));
sink.write_little_endian<uint32_t>(header.version());
sink.write_little_endian<uint32_t>(header.timestamp());
sink.write_little_endian<uint32_t>(header.bits());
Expand Down Expand Up @@ -144,109 +187,117 @@ struct header
key key{};
};

struct get_version
struct record_context
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::size + schema::bit + link::size);
version = source.read_little_endian<uint32_t>();
context::from_data(source, ctx);
return source;
}

uint32_t version{};
context ctx{};
};

struct get_timestamp
struct get_flags
: public schema::header
{
using flag_t = context::flag_t;
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::size + schema::bit + link::size +
sizeof(uint32_t));
timestamp = source.read_little_endian<uint32_t>();
flags = source.read_little_endian<flag_t::integer, flag_t::size>();
return source;
}

uint32_t timestamp{};
flag_t::integer flags{};
};

struct get_bits
struct get_height
: public schema::header
{
using height_t = context::height_t;
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::size + schema::bit + link::size +
sizeof(uint32_t) + sizeof(uint32_t));
bits = source.read_little_endian<uint32_t>();
source.skip_bytes(skip_to_height);
height = source.read_little_endian<height_t::integer, height_t::size>();
return source;
}

uint32_t bits{};
height_t::integer height{};
};

struct get_mtp
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(skip_to_mtp);
mtp = source.read_little_endian<uint32_t>();
return source;
}

context::mtp_t mtp{};
};

struct get_parent_fk
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::size + schema::bit);
parent_fk = source.read_little_endian<link::integer, link::size>();
source.skip_bytes(skip_to_parent);
parent_fk = to_parent(source.read_little_endian<link::integer, link::size>());
return source;
}

link::integer parent_fk{};
};

struct get_flags
struct get_version
: public schema::header
{
using flag_t = context::flag_t;

inline bool from_data(reader& source) NOEXCEPT
{
flags = source.read_little_endian<flag_t::integer, flag_t::size>();
source.skip_bytes(skip_to_version);
version = source.read_little_endian<uint32_t>();
return source;
}

flag_t::integer flags{};
uint32_t version{};
};

struct get_height
struct get_timestamp
: public schema::header
{
using height_t = context::height_t;

inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::flag_t::size);
height = source.read_little_endian<height_t::integer, height_t::size>();
source.skip_bytes(skip_to_timestamp);
timestamp = source.read_little_endian<uint32_t>();
return source;
}

height_t::integer height{};
uint32_t timestamp{};
};

struct get_mtp
struct get_bits
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::flag_t::size + context::height_t::size);
mtp = source.read_little_endian<uint32_t>();
source.skip_bytes(skip_to_bits);
bits = source.read_little_endian<uint32_t>();
return source;
}

context::mtp_t mtp{};
uint32_t bits{};
};

struct get_milestone
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
source.skip_bytes(context::size);
milestone = to_bool(source.read_byte());
source.skip_bytes(skip_to_parent);
milestone = is_milestone(source.read_little_endian<link::integer, link::size>());
return source;
}

Expand All @@ -261,7 +312,7 @@ struct header
source.rewind_bytes(sk);
key = source.read_hash();
context::from_data(source, ctx);
source.skip_bytes(schema::bit + link::size + sizeof(uint32_t));
source.skip_bytes(skip_to_timestamp - skip_to_parent);
timestamp = source.read_little_endian<uint32_t>();
return source;
}
Expand All @@ -270,18 +321,6 @@ struct header
context ctx{};
uint32_t timestamp{};
};

struct record_context
: public schema::header
{
inline bool from_data(reader& source) NOEXCEPT
{
context::from_data(source, ctx);
return source;
}

context ctx{};
};
};

} // namespace table
Expand Down
Loading
Loading