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
2 changes: 0 additions & 2 deletions builds/gnu/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ include_bitcoin_database_tables_archives_HEADERS = \
${srcdir}/../../include/bitcoin/database/tables/archives/ins.hpp \
${srcdir}/../../include/bitcoin/database/tables/archives/output.hpp \
${srcdir}/../../include/bitcoin/database/tables/archives/outs.hpp \
${srcdir}/../../include/bitcoin/database/tables/archives/point.hpp \
${srcdir}/../../include/bitcoin/database/tables/archives/transaction.hpp \
${srcdir}/../../include/bitcoin/database/tables/archives/txs.hpp

Expand Down Expand Up @@ -432,7 +431,6 @@ test_libbitcoin_database_test_SOURCES = \
${srcdir}/../../test/tables/archives/ins.cpp \
${srcdir}/../../test/tables/archives/output.cpp \
${srcdir}/../../test/tables/archives/outs.cpp \
${srcdir}/../../test/tables/archives/point.cpp \
${srcdir}/../../test/tables/archives/transaction.cpp \
${srcdir}/../../test/tables/archives/txs.cpp \
${srcdir}/../../test/tables/caches/duplicate.cpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
<ClCompile Include="..\..\..\..\test\tables\archives\ins.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\output.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\outs.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\point.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\transaction.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\txs.cpp" />
<ClCompile Include="..\..\..\..\test\tables\caches\duplicate.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@
<ClCompile Include="..\..\..\..\test\tables\archives\outs.cpp">
<Filter>src\tables\archives</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\tables\archives\point.cpp">
<Filter>src\tables\archives</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\tables\archives\transaction.cpp">
<Filter>src\tables\archives</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\ins.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\output.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\outs.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\point.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\transaction.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\txs.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\duplicate.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\outs.hpp">
<Filter>include\bitcoin\database\tables\archives</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\point.hpp">
<Filter>include\bitcoin\database\tables\archives</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\transaction.hpp">
<Filter>include\bitcoin\database\tables\archives</Filter>
</ClInclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
<ClCompile Include="..\..\..\..\test\tables\archives\ins.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\output.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\outs.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\point.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\transaction.cpp" />
<ClCompile Include="..\..\..\..\test\tables\archives\txs.cpp" />
<ClCompile Include="..\..\..\..\test\tables\caches\duplicate.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@
<ClCompile Include="..\..\..\..\test\tables\archives\outs.cpp">
<Filter>src\tables\archives</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\tables\archives\point.cpp">
<Filter>src\tables\archives</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\tables\archives\transaction.cpp">
<Filter>src\tables\archives</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\ins.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\output.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\outs.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\point.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\transaction.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\txs.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\caches\duplicate.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\outs.hpp">
<Filter>include\bitcoin\database\tables\archives</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\point.hpp">
<Filter>include\bitcoin\database\tables\archives</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\archives\transaction.hpp">
<Filter>include\bitcoin\database\tables\archives</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion include/bitcoin/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
#include <bitcoin/database/tables/archives/ins.hpp>
#include <bitcoin/database/tables/archives/output.hpp>
#include <bitcoin/database/tables/archives/outs.hpp>
#include <bitcoin/database/tables/archives/point.hpp>
#include <bitcoin/database/tables/archives/transaction.hpp>
#include <bitcoin/database/tables/archives/txs.hpp>
#include <bitcoin/database/tables/caches/duplicate.hpp>
Expand Down
17 changes: 17 additions & 0 deletions include/bitcoin/database/impl/primitives/hashmaps.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ Link CLASS::count() const NOEXCEPT
return body_.count();
}

// diagnostic counters
// ----------------------------------------------------------------------------

TEMPLATE
size_t CLASS::positive_search_count() const NOEXCEPT
{
return positive_.load(std::memory_order_relaxed);
}

TEMPLATE
size_t CLASS::negative_search_count() const NOEXCEPT
{
return negative_.load(std::memory_order_relaxed);
}

// error condition
// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -382,11 +397,13 @@ inline bool CLASS::put(bool& duplicate, const memory& ptr,
if (previous.is_terminal())
{
duplicate = false;
////negative_.fetch_add(one, std::memory_order_relaxed);
}
else
{
// Search the previous conflicts to determine if actual duplicate.
duplicate = !first(ptr, previous, key).is_terminal();
////positive_.fetch_add(one, std::memory_order_relaxed);
}

return true;
Expand Down
40 changes: 20 additions & 20 deletions include/bitcoin/database/impl/query/archive/chain_reader.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -191,45 +191,45 @@ typename CLASS::transaction::cptr CLASS::get_transaction(const tx_link& link,
return ptr;
}

// point_link->point
// ins_link->point
// ----------------------------------------------------------------------------

TEMPLATE
typename CLASS::point CLASS::get_point(
const point_link& link) const NOEXCEPT
const ins_link& link) const NOEXCEPT
{
table::point::record point{};
if (!store_.point.get(link, point))
table::ins_point::record point{};
if (!store_.ins.get(link, point))
return {};

return { point.hash, point.index };
}

// point_link->witness
// ins_link->witness
// ----------------------------------------------------------------------------

TEMPLATE
typename CLASS::witness::cptr CLASS::get_witness(
const point_link& link) const NOEXCEPT
const ins_link& link) const NOEXCEPT
{
table::input::get_witness in{};
table::ins::get_input ins{};
if (!store_.ins.get(link, ins) ||
table::ins_sequence::get_input ins{};
if (!store_.ins.sequence.get(link, ins) ||
!store_.input.get(ins.input_fk, in))
return {};

return in.witness;
}

// point_link->input_script
// ins_link->input_script
// ----------------------------------------------------------------------------
TEMPLATE
typename CLASS::script::cptr CLASS::get_input_script(
const point_link& link) const NOEXCEPT
const ins_link& link) const NOEXCEPT
{
table::input::get_script in{};
table::ins::get_input ins{};
if (!store_.ins.get(link, ins) ||
table::ins_sequence::get_input ins{};
if (!store_.ins.sequence.get(link, ins) ||
!store_.input.get(ins.input_fk, in))
return {};

Expand All @@ -246,19 +246,19 @@ typename CLASS::input::cptr CLASS::get_input(const tx_link& link,
return get_input(to_point(link, index), witness);
}

// point_link->input
// ins_link->input
// ----------------------------------------------------------------------------

TEMPLATE
typename CLASS::input::cptr CLASS::get_input(const point_link& link,
typename CLASS::input::cptr CLASS::get_input(const ins_link& link,
bool witness) const NOEXCEPT
{
using namespace system;
table::input::get_ptrs in{ {}, witness };
table::ins::get_input ins{};
table::point::record point{};
if (!store_.ins.get(link, ins) ||
!store_.point.get(link, point) ||
table::ins_sequence::get_input ins{};
table::ins_point::record point{};
if (!store_.ins.sequence.get(link, ins) ||
!store_.ins.get(link, point) ||
!store_.input.get(ins.input_fk, in))
return {};

Expand Down Expand Up @@ -350,11 +350,11 @@ inpoints CLASS::get_spenders(const point& point) const NOEXCEPT
return ins;
}

// point_link->inpoint[spender]
// ins_link->inpoint[spender]
// ----------------------------------------------------------------------------

TEMPLATE
inpoint CLASS::get_spender(const point_link& link) const NOEXCEPT
inpoint CLASS::get_spender(const ins_link& link) const NOEXCEPT
{
const auto tx_fk = to_input_tx(link);
if (tx_fk.is_terminal())
Expand Down
40 changes: 20 additions & 20 deletions include/bitcoin/database/impl/query/archive/chain_writer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,20 @@ code CLASS::set_code(const tx_link& tx_fk, const transaction& tx,
table::output::put_ref{ {}, tx_fk, tx }))
return error::tx_output_put;

// Allocate and contiguously store input links.
ins_link ins_fk{};
if (!store_.ins.put_link(ins_fk,
table::ins::put_ref{ {}, in_fk, tx_fk, tx }))
// Allocate ins/point rows and contiguously store input links.
// Point elements are set into the same rows following tx set, below.
auto ins_fk = store_.ins.allocate(inputs);
if (ins_fk.is_terminal())
return error::tx_ins_put;

// Ins put is unguarded, the accessor guards its rows against remap.
auto insert = store_.ins.get_memory();
if (!insert || !store_.ins.sequence.put(ins_fk,
table::ins_sequence::put_ref{ {}, in_fk, tx_fk, tx }))
return error::tx_ins_put;

insert.reset();

// Allocate and contiguously store output links.
outs_link outs_fk{};
if (!store_.outs.put_link(outs_fk,
Expand All @@ -149,21 +157,13 @@ code CLASS::set_code(const tx_link& tx_fk, const transaction& tx,
if (coinbase)
{
// Should only be one input, but generalized anyway.
if (!store_.point.expand(ins_fk + inputs))
return error::tx_point_allocate;

for (const auto& in: *ins)
if (!store_.point.put(ins_fk++, in->point(),
table::point::record{}))
if (!store_.ins.put(ins_fk++, in->point(),
table::ins_point::record{}))
return error::tx_null_point_put;
}
else
{
// Expand synchronizes keys with ins_fk, entries set into same offset.
// Allocate contiguous points (at sequential keys matching ins_fk).
if (!store_.point.expand(ins_fk + inputs))
return error::tx_point_allocate;

// If dirty we must guard against duplicates. Dirty is caused by disk,
// full, disorganized or reorganized block, and tx pooling. It is set
// to true at runtime by any of these and in case of duplicate table
Expand All @@ -174,12 +174,12 @@ code CLASS::set_code(const tx_link& tx_fk, const transaction& tx,
{
// Collect duplicates to store in duplicate table.
std::vector<chain::point> twins{};
auto ptr = store_.point.get_memory();
auto ptr = store_.ins.get_memory();
for (const auto& in: *ins)
{
bool duplicate{};
if (!store_.point.put(duplicate, ptr, ins_fk++, in->point(),
table::point::record{}))
if (!store_.ins.put(duplicate, ptr, ins_fk++, in->point(),
table::ins_point::record{}))
return error::tx_point_put;

if (duplicate)
Expand All @@ -197,10 +197,10 @@ code CLASS::set_code(const tx_link& tx_fk, const transaction& tx,
}
else
{
auto ptr = store_.point.get_memory();
auto ptr = store_.ins.get_memory();
for (const auto& in: *ins)
if (!store_.point.put(ptr, ins_fk++, in->point(),
table::point::record{}))
if (!store_.ins.put(ptr, ins_fk++, in->point(),
table::ins_point::record{}))
return error::tx_point_put;

ptr.reset();
Expand Down
16 changes: 8 additions & 8 deletions include/bitcoin/database/impl/query/archive/wire_reader.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ bool CLASS::get_wire_header(bytewriter& sink,

TEMPLATE
bool CLASS::get_wire_input(bytewriter& sink,
const point_link& link) const NOEXCEPT
const ins_link& link) const NOEXCEPT
{
table::point::wire_point point{ {}, sink };
if (!store_.point.get(link, point))
table::ins_point::wire_point point{ {}, sink };
if (!store_.ins.get(link, point))
return false;

table::ins::get_input ins{};
table::ins_sequence::get_input ins{};
table::input::wire_script script{ {}, sink };
if (!store_.ins.get(link, ins) ||
if (!store_.ins.sequence.get(link, ins) ||
!store_.input.get(ins.input_fk, script))
return false;

Expand All @@ -70,11 +70,11 @@ bool CLASS::get_wire_output(bytewriter& sink,

TEMPLATE
bool CLASS::get_wire_witness(bytewriter& sink,
const point_link& link) const NOEXCEPT
const ins_link& link) const NOEXCEPT
{
table::ins::get_input ins{};
table::ins_sequence::get_input ins{};
table::input::wire_witness wire{ {}, sink };
return store_.ins.get(link, ins)
return store_.ins.sequence.get(link, ins)
&& store_.input.get(ins.input_fk, wire);
}

Expand Down
Loading
Loading