Skip to content

Commit a02507c

Browse files
authored
Merge pull request #570 from evoskuil/master
Split point table: schema, table, query, and store changes.
2 parents 4a1a31f + f9d43de commit a02507c

42 files changed

Lines changed: 529 additions & 356 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ include_bitcoin_database_tables_archivesdir = ${includedir}/bitcoin/database/tab
232232
include_bitcoin_database_tables_archives_HEADERS = \
233233
include/bitcoin/database/tables/archives/header.hpp \
234234
include/bitcoin/database/tables/archives/input.hpp \
235+
include/bitcoin/database/tables/archives/ins.hpp \
235236
include/bitcoin/database/tables/archives/output.hpp \
236237
include/bitcoin/database/tables/archives/point.hpp \
237238
include/bitcoin/database/tables/archives/puts.hpp \

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
<ClInclude Include="..\..\..\..\include\bitcoin\database\store.hpp" />
128128
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\header.hpp" />
129129
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\input.hpp" />
130+
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\ins.hpp" />
130131
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\output.hpp" />
131132
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\point.hpp" />
132133
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\puts.hpp" />

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@
224224
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\input.hpp">
225225
<Filter>include\bitcoin\database\tables\archives</Filter>
226226
</ClInclude>
227+
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\ins.hpp">
228+
<Filter>include\bitcoin\database\tables\archives</Filter>
229+
</ClInclude>
227230
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\output.hpp">
228231
<Filter>include\bitcoin\database\tables\archives</Filter>
229232
</ClInclude>

include/bitcoin/database.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include <bitcoin/database/tables/tables.hpp>
5959
#include <bitcoin/database/tables/archives/header.hpp>
6060
#include <bitcoin/database/tables/archives/input.hpp>
61+
#include <bitcoin/database/tables/archives/ins.hpp>
6162
#include <bitcoin/database/tables/archives/output.hpp>
6263
#include <bitcoin/database/tables/archives/point.hpp>
6364
#include <bitcoin/database/tables/archives/puts.hpp>

include/bitcoin/database/error.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ enum error_t : uint8_t
120120
tx_input_put,
121121
tx_point_allocate,
122122
tx_point_put,
123+
tx_ins_allocate,
124+
tx_ins_put,
123125
tx_output_put,
124126
tx_puts_put,
125127
tx_tx_set,

include/bitcoin/database/impl/primitives/manager.ipp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ bool CLASS::truncate(const Link& count) NOEXCEPT
5252
return file_.truncate(link_to_position(count));
5353
}
5454

55+
TEMPLATE
56+
bool CLASS::expand(const Link& count) NOEXCEPT
57+
{
58+
if (count.is_terminal())
59+
return false;
60+
61+
return file_.expand(link_to_position(count));
62+
}
63+
5564
TEMPLATE
5665
Link CLASS::allocate(const Link& size) NOEXCEPT
5766
{

include/bitcoin/database/impl/primitives/nomap.ipp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ bool CLASS::truncate(const Link& count) NOEXCEPT
103103
return manager_.truncate(count);
104104
}
105105

106+
TEMPLATE
107+
bool CLASS::expand(const Link& count) NOEXCEPT
108+
{
109+
return manager_.expand(count);
110+
}
111+
106112
// error condition
107113
// ----------------------------------------------------------------------------
108114

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ inline hash_digest CLASS::get_tx_key(const tx_link& link) const NOEXCEPT
114114
TEMPLATE
115115
inline hash_digest CLASS::get_point_key(const point_link& link) const NOEXCEPT
116116
{
117-
table::point::get_key point{};
117+
table::point::record point{};
118118
if (!store_.point.get(link, point))
119119
return {};
120120

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ code CLASS::set_code(tx_link& tx_fk, const transaction& tx) NOEXCEPT
115115
if (point_fk.is_terminal())
116116
return error::tx_point_allocate;
117117

118-
// Commit input and point records.
118+
// Expand synchronizes keys with point allocation.
119+
if (!store_.ins.expand(point_fk + inputs))
120+
return error::tx_ins_allocate;
121+
122+
// Commit input and ins|point records.
119123
for (const auto& in: *ins)
120124
{
121125
input_link input_fk{};
@@ -128,15 +132,23 @@ code CLASS::set_code(tx_link& tx_fk, const transaction& tx) NOEXCEPT
128132
return error::tx_input_put;
129133
}
130134

131-
if (!store_.point.put(point_it++, table::point::record
135+
if (!store_.ins.put(point_it, table::ins::record
132136
{
133137
{},
134-
in->point().hash(),
135138
in->point().index(),
136139
in->sequence(),
137140
input_fk,
138141
tx_fk
139142
}))
143+
{
144+
return error::tx_ins_put;
145+
}
146+
147+
if (!store_.point.put(point_it++, table::point::record_ref
148+
{
149+
{},
150+
in->point().hash()
151+
}))
140152
{
141153
return error::tx_point_put;
142154
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ bool CLASS::is_spent_output(const output_link& link) const NOEXCEPT
106106
////TEMPLATE
107107
////bool CLASS::is_spent(const point_link& link) const NOEXCEPT
108108
////{
109-
//// table::point::get_prevout_parent spend{};
109+
//// table::ins::get_index spend{};
110110
//// if (!store_.spend.get(link, spend))
111111
//// return false;
112112
////
113113
//// if (spend.is_null())
114114
//// return false;
115115
////
116116
//// // Prevout is spent by any confirmed transaction.
117-
//// return is_spent_prevout(link, spend.point_index);
117+
//// return is_spent_prevout(link, spend.index);
118118
////}
119119

120120
TEMPLATE

0 commit comments

Comments
 (0)