Skip to content

Commit a5adf33

Browse files
committed
Rough in doubles schema, table and settings.
1 parent fb94c79 commit a5adf33

14 files changed

Lines changed: 150 additions & 2 deletions

File tree

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ test_libbitcoin_database_test_SOURCES = \
9999
test/tables/archives/puts.cpp \
100100
test/tables/archives/transaction.cpp \
101101
test/tables/archives/txs.cpp \
102+
test/tables/caches/doubles.cpp \
102103
test/tables/caches/prevout.cpp \
103104
test/tables/caches/validated_bk.cpp \
104105
test/tables/caches/validated_tx.cpp \
@@ -240,6 +241,7 @@ include_bitcoin_database_tables_archives_HEADERS = \
240241

241242
include_bitcoin_database_tables_cachesdir = ${includedir}/bitcoin/database/tables/caches
242243
include_bitcoin_database_tables_caches_HEADERS = \
244+
include/bitcoin/database/tables/caches/doubles.hpp \
243245
include/bitcoin/database/tables/caches/prevout.hpp \
244246
include/bitcoin/database/tables/caches/validated_bk.hpp \
245247
include/bitcoin/database/tables/caches/validated_tx.hpp

builds/cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ if (with-tests)
307307
"../../test/tables/archives/puts.cpp"
308308
"../../test/tables/archives/transaction.cpp"
309309
"../../test/tables/archives/txs.cpp"
310+
"../../test/tables/caches/doubles.cpp"
310311
"../../test/tables/caches/prevout.cpp"
311312
"../../test/tables/caches/validated_bk.cpp"
312313
"../../test/tables/caches/validated_tx.cpp"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
<ClCompile Include="..\..\..\..\test\tables\archives\puts.cpp" />
111111
<ClCompile Include="..\..\..\..\test\tables\archives\transaction.cpp" />
112112
<ClCompile Include="..\..\..\..\test\tables\archives\txs.cpp" />
113+
<ClCompile Include="..\..\..\..\test\tables\caches\doubles.cpp" />
113114
<ClCompile Include="..\..\..\..\test\tables\caches\prevout.cpp" />
114115
<ClCompile Include="..\..\..\..\test\tables\caches\validated_bk.cpp" />
115116
<ClCompile Include="..\..\..\..\test\tables\caches\validated_tx.cpp" />

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@
153153
<ClCompile Include="..\..\..\..\test\tables\archives\txs.cpp">
154154
<Filter>src\tables\archives</Filter>
155155
</ClCompile>
156+
<ClCompile Include="..\..\..\..\test\tables\caches\doubles.cpp">
157+
<Filter>src\tables\caches</Filter>
158+
</ClCompile>
156159
<ClCompile Include="..\..\..\..\test\tables\caches\prevout.cpp">
157160
<Filter>src\tables\caches</Filter>
158161
</ClCompile>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\point.hpp" />
134134
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\transaction.hpp" />
135135
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\txs.hpp" />
136+
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\doubles.hpp" />
136137
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\prevout.hpp" />
137138
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\validated_bk.hpp" />
138139
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\validated_tx.hpp" />

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@
242242
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\txs.hpp">
243243
<Filter>include\bitcoin\database\tables\archives</Filter>
244244
</ClInclude>
245+
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\doubles.hpp">
246+
<Filter>include\bitcoin\database\tables\caches</Filter>
247+
</ClInclude>
245248
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\prevout.hpp">
246249
<Filter>include\bitcoin\database\tables\caches</Filter>
247250
</ClInclude>

include/bitcoin/database.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include <bitcoin/database/tables/archives/point.hpp>
6565
#include <bitcoin/database/tables/archives/transaction.hpp>
6666
#include <bitcoin/database/tables/archives/txs.hpp>
67+
#include <bitcoin/database/tables/caches/doubles.hpp>
6768
#include <bitcoin/database/tables/caches/prevout.hpp>
6869
#include <bitcoin/database/tables/caches/validated_bk.hpp>
6970
#include <bitcoin/database/tables/caches/validated_tx.hpp>

include/bitcoin/database/settings.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ struct BCD_API settings
9090
uint64_t prevout_size;
9191
uint16_t prevout_rate;
9292

93+
uint32_t doubles_bits;
94+
uint64_t doubles_size;
95+
uint16_t doubles_rate;
96+
9397
uint32_t validated_bk_bits;
9498
uint64_t validated_bk_size;
9599
uint16_t validated_bk_rate;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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_TABLES_CACHES_DOUBLES_HPP
20+
#define LIBBITCOIN_DATABASE_TABLES_CACHES_DOUBLES_HPP
21+
22+
#include <utility>
23+
#include <bitcoin/system.hpp>
24+
#include <bitcoin/database/define.hpp>
25+
#include <bitcoin/database/primitives/primitives.hpp>
26+
#include <bitcoin/database/tables/schema.hpp>
27+
28+
namespace libbitcoin {
29+
namespace database {
30+
namespace table {
31+
32+
// TODO: this table isn't actually mapped.
33+
struct doubles
34+
: public hash_map<schema::doubles>
35+
{
36+
using hash_map<schema::doubles>::hashmap;
37+
using ix = linkage<schema::index>;
38+
39+
// This supports only a single record (not too useful).
40+
struct record
41+
: public schema::doubles
42+
{
43+
inline bool from_data(reader& source) NOEXCEPT
44+
{
45+
hash = source.read_hash();
46+
index = source.read_little_endian<ix::integer, ix::size>();
47+
BC_ASSERT(!source || source.get_read_position() == count());
48+
return source;
49+
}
50+
51+
inline bool to_data(finalizer& sink) const NOEXCEPT
52+
{
53+
sink.write_bytes(hash);
54+
sink.write_little_endian<ix::integer, ix::size>(index);
55+
BC_ASSERT(!sink || sink.get_write_position() == count());
56+
return sink;
57+
}
58+
59+
inline bool operator==(const record& other) const NOEXCEPT
60+
{
61+
return hash == other.hash
62+
&& index == other.index;
63+
}
64+
65+
hash_digest hash{};
66+
ix::integer index{};
67+
};
68+
};
69+
70+
} // namespace table
71+
} // namespace database
72+
} // namespace libbitcoin
73+
74+
#endif

include/bitcoin/database/tables/caches/prevout.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* You should have received a copy of the GNU Affero General Public License
1717
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19-
#ifndef LIBBITCOIN_DATABASE_TABLES_OPTIONALS_BUFFER_HPP
20-
#define LIBBITCOIN_DATABASE_TABLES_OPTIONALS_BUFFER_HPP
19+
#ifndef LIBBITCOIN_DATABASE_TABLES_CACHES_PREVOUT_HPP
20+
#define LIBBITCOIN_DATABASE_TABLES_CACHES_PREVOUT_HPP
2121

2222
#include <utility>
2323
#include <bitcoin/system.hpp>

0 commit comments

Comments
 (0)