Skip to content

Commit 2797f02

Browse files
committed
Create separate header for namespace level typedefs.
1 parent f708fca commit 2797f02

7 files changed

Lines changed: 74 additions & 34 deletions

File tree

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ include_bitcoin_database_HEADERS = \
144144
include/bitcoin/database/query.hpp \
145145
include/bitcoin/database/settings.hpp \
146146
include/bitcoin/database/store.hpp \
147+
include/bitcoin/database/types.hpp \
147148
include/bitcoin/database/version.hpp
148149

149150
include_bitcoin_database_filedir = ${includedir}/bitcoin/database/file

builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\states.hpp" />
198198
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\table.hpp" />
199199
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\tables.hpp" />
200+
<ClInclude Include="..\..\..\..\include\bitcoin\database\types.hpp" />
200201
<ClInclude Include="..\..\..\..\include\bitcoin\database\version.hpp" />
201202
<ClInclude Include="..\..\..\..\src\memory\mman-win32\mman.hpp" />
202203
</ItemGroup>

builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@
290290
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\tables.hpp">
291291
<Filter>include\bitcoin\database\tables</Filter>
292292
</ClInclude>
293+
<ClInclude Include="..\..\..\..\include\bitcoin\database\types.hpp">
294+
<Filter>include\bitcoin\database</Filter>
295+
</ClInclude>
293296
<ClInclude Include="..\..\..\..\include\bitcoin\database\version.hpp">
294297
<Filter>include\bitcoin\database</Filter>
295298
</ClInclude>

include/bitcoin/database.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <bitcoin/database/query.hpp>
2222
#include <bitcoin/database/settings.hpp>
2323
#include <bitcoin/database/store.hpp>
24+
#include <bitcoin/database/types.hpp>
2425
#include <bitcoin/database/version.hpp>
2526
#include <bitcoin/database/file/file.hpp>
2627
#include <bitcoin/database/file/rotator.hpp>

include/bitcoin/database/impl/query/consensus.ipp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool CLASS::is_strong(const tx_link& tx) const NOEXCEPT
185185

186186
// protected
187187
TEMPLATE
188-
error::error_t CLASS::unspendable(uint32_t sequence, bool coinbase,
188+
code CLASS::unspendable(uint32_t sequence, bool coinbase,
189189
const tx_link& tx, uint32_t version, const context& ctx) const NOEXCEPT
190190
{
191191
// Ensure prevout tx is in a strong block, first try self link.
@@ -317,27 +317,27 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
317317

318318
// Get points for each tx, and sum the total number.
319319
std::transform(parallel, txs.begin(), txs.end(), sets.begin(), to_set);
320-
if (failure)
321-
return { failure.load() };
320+
if (failure != error::success)
321+
return failure;
322322

323323
// Check double spends strength, populates prevout parent tx/cb/sq links.
324324
if ((ec = populate_prevouts(sets, points, link)))
325325
return ec;
326326

327-
const auto is_unspendable = [this, &ctx, &failure](const auto& set) NOEXCEPT
327+
const bool is_spendable = [this, &ctx, &failure](const auto& set) NOEXCEPT
328328
{
329329
error::error_t ec{};
330330
for (const auto& point: set.points)
331331
if (!point.tx.is_terminal() && ((ec = unspendable(point.sequence,
332332
point.coinbase, point.tx, set.version, ctx))))
333333
failure.store(ec);
334334

335-
return failure != error::success;
335+
return failure == error::success;
336336
};
337337

338338
// Check all spends for spendability (strong, unlocked and mature).
339-
if (std::any_of(parallel, sets.begin(), sets.end(), is_unspendable))
340-
return { failure.load() };
339+
if (!std::all_of(parallel, sets.begin(), sets.end(), is_spendable))
340+
return failure;
341341

342342
return error::success;
343343
}

include/bitcoin/database/query.hpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,11 @@
2424
#include <utility>
2525
#include <bitcoin/system.hpp>
2626
#include <bitcoin/database/define.hpp>
27-
#include <bitcoin/database/error.hpp>
28-
#include <bitcoin/database/primitives/primitives.hpp>
29-
#include <bitcoin/database/tables/tables.hpp>
27+
#include <bitcoin/database/types.hpp>
3028

3129
namespace libbitcoin {
3230
namespace database {
3331

34-
/// Database type aliases.
35-
using height_link = table::height::link;
36-
using header_link = table::header::link;
37-
using output_link = table::output::link;
38-
using input_link = table::input::link;
39-
using outs_link = table::outs::link;
40-
using ins_link = table::ins::link;
41-
using point_link = table::point::link;
42-
using tx_link = table::transaction::link;
43-
using filter_link = table::filter_tx::link;
44-
using strong_link = table::strong_tx::link;
45-
46-
using header_links = std::vector<header_link::integer>;
47-
using tx_links = std::vector<tx_link::integer>;
48-
using input_links = std::vector<input_link::integer>;
49-
using output_links = std::vector<output_link::integer>;
50-
using point_links = std::vector<point_link::integer>;
51-
using two_counts = std::pair<size_t, size_t>;
52-
using point_key = table::point::key;
53-
54-
struct header_state{ header_link link; code ec; };
55-
using header_states = std::vector<header_state>;
56-
5732
// Writers (non-const) are only: push_, pop_, set_ and initialize.
5833
template <typename Store>
5934
class query
@@ -652,7 +627,7 @@ class query
652627
const context& ctx) const NOEXCEPT;
653628

654629
/// Called by block_confirmable (populate and check double spends).
655-
error::error_t unspendable(uint32_t sequence, bool coinbase,
630+
code unspendable(uint32_t sequence, bool coinbase,
656631
const tx_link& prevout_tx, uint32_t version,
657632
const context& ctx) const NOEXCEPT;
658633

include/bitcoin/database/types.hpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#ifndef LIBBITCOIN_DATABASE_TYPES_HPP
20+
#define LIBBITCOIN_DATABASE_TYPES_HPP
21+
22+
#include <set>
23+
#include <utility>
24+
#include <bitcoin/database/define.hpp>
25+
#include <bitcoin/database/tables/tables.hpp>
26+
27+
namespace libbitcoin {
28+
namespace database {
29+
30+
/// Database type aliases.
31+
using height_link = table::height::link;
32+
using header_link = table::header::link;
33+
using output_link = table::output::link;
34+
using input_link = table::input::link;
35+
using outs_link = table::outs::link;
36+
using ins_link = table::ins::link;
37+
using point_link = table::point::link;
38+
using tx_link = table::transaction::link;
39+
using filter_link = table::filter_tx::link;
40+
using strong_link = table::strong_tx::link;
41+
42+
using header_links = std::vector<header_link::integer>;
43+
using tx_links = std::vector<tx_link::integer>;
44+
using input_links = std::vector<input_link::integer>;
45+
using output_links = std::vector<output_link::integer>;
46+
using point_links = std::vector<point_link::integer>;
47+
using two_counts = std::pair<size_t, size_t>;
48+
using point_key = table::point::key;
49+
50+
struct header_state{ header_link link; code ec; };
51+
using header_states = std::vector<header_state>;
52+
53+
using inpoint_set = std::set<system::chain::point>;
54+
using outpoint_set = std::set<system::chain::outpoint>;
55+
56+
} // namespace database
57+
} // namespace libbitcoin
58+
59+
#endif

0 commit comments

Comments
 (0)