Skip to content

Commit 24f2c4c

Browse files
committed
Remove set_txs_connected and set_tx_preconnected.
1 parent 8609655 commit 24f2c4c

File tree

4 files changed

+46
-96
lines changed

4 files changed

+46
-96
lines changed

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

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ inline code CLASS::to_block_code(
3636
{
3737
switch (value)
3838
{
39-
// Block satisfies validation rules (prevouts unverified).
39+
// Transitional: Satisfies validation rules (prevouts unverified).
4040
case schema::block_state::valid:
4141
return error::block_valid;
42-
// Final: Block satisfies confirmation rules (prevouts).
42+
// Final: Satisfies confirmation rules (prevouts confirmable).
4343
case schema::block_state::confirmable:
4444
return error::block_confirmable;
45-
// Final: Block does not satisfy validation/confirmation rules.
45+
// Final: Does not satisfy either validation or confirmation rules.
4646
case schema::block_state::unconfirmable:
4747
return error::block_unconfirmable;
48-
// Block has no recorded state, may be under checkpoint or milestone.
48+
// Fault: Has no state, should not happen when read from store.
4949
default:
5050
return error::unknown_state;
5151
}
@@ -61,16 +61,13 @@ inline code CLASS::to_tx_code(
6161
// All states below are relevant only to the associated validation context.
6262
switch (value)
6363
{
64-
// Tx is valid in the case where standard prevouts are matched.
65-
case schema::tx_state::preconnected:
66-
return error::tx_preconnected;
67-
// Final: Tx is valid (passed check, accept, and connect).
64+
// Final: Is valid (passed check, accept, and connect).
6865
case schema::tx_state::connected:
6966
return error::tx_connected;
70-
// Final: Tx is not valid (failed check, accept, or connect).
67+
// Final: Is not valid (failed check, accept, or connect).
7168
case schema::tx_state::disconnected:
7269
return error::tx_disconnected;
73-
// Tx has no recorded state, may be under checkpoint or milestone.
70+
// Fault: Has no state, should not happen when read from store.
7471
default:
7572
return error::unknown_state;
7673
}
@@ -307,25 +304,6 @@ bool CLASS::set_block_unconfirmable(const header_link& link) NOEXCEPT
307304
// ========================================================================
308305
}
309306

310-
TEMPLATE
311-
bool CLASS::set_tx_preconnected(const tx_link& link,
312-
const context& ctx) NOEXCEPT
313-
{
314-
// ========================================================================
315-
const auto scope = store_.get_transactor();
316-
317-
// Clean single allocation failure (e.g. disk full).
318-
return store_.validated_tx.put(link, table::validated_tx::slab
319-
{
320-
{},
321-
ctx,
322-
schema::tx_state::preconnected,
323-
0, // fee
324-
0 // sigops
325-
});
326-
// ========================================================================
327-
}
328-
329307
TEMPLATE
330308
bool CLASS::set_tx_disconnected(const tx_link& link,
331309
const context& ctx) NOEXCEPT
@@ -367,40 +345,40 @@ bool CLASS::set_tx_connected(const tx_link& link, const context& ctx,
367345
// ========================================================================
368346
}
369347

370-
TEMPLATE
371-
bool CLASS::set_txs_connected(const header_link& link) NOEXCEPT
372-
{
373-
context ctx{};
374-
if (!get_context(ctx, link))
375-
return false;
376-
377-
const auto txs = to_transactions(link);
378-
if (txs.empty())
379-
return false;
380-
381-
// FOR PERFORMANCE EVALUATION ONLY.
382-
constexpr uint64_t fee = 99;
383-
constexpr size_t sigops = 42;
384-
using sigs = linkage<schema::sigops>;
385-
386-
// ========================================================================
387-
const auto scope = store_.get_transactor();
388-
389-
// Clean single allocation failure (e.g. disk full).
390-
return std_all_of(bc::seq, txs.begin(), txs.end(),
391-
[&](const tx_link& fk) NOEXCEPT
392-
{
393-
return store_.validated_tx.put(fk, table::validated_tx::slab
394-
{
395-
{},
396-
ctx,
397-
schema::tx_state::connected,
398-
fee,
399-
system::possible_narrow_cast<sigs::integer>(sigops)
400-
});
401-
});
402-
// ========================================================================
403-
}
348+
////TEMPLATE
349+
////bool CLASS::set_txs_connected(const header_link& link) NOEXCEPT
350+
////{
351+
//// context ctx{};
352+
//// if (!get_context(ctx, link))
353+
//// return false;
354+
////
355+
//// const auto txs = to_transactions(link);
356+
//// if (txs.empty())
357+
//// return false;
358+
////
359+
//// // FOR PERFORMANCE EVALUATION ONLY.
360+
//// constexpr uint64_t fee = 99;
361+
//// constexpr size_t sigops = 42;
362+
//// using sigs = linkage<schema::sigops>;
363+
////
364+
//// // ========================================================================
365+
//// const auto scope = store_.get_transactor();
366+
////
367+
//// // Clean single allocation failure (e.g. disk full).
368+
//// return std_all_of(bc::seq, txs.begin(), txs.end(),
369+
//// [&](const tx_link& fk) NOEXCEPT
370+
//// {
371+
//// return store_.validated_tx.put(fk, table::validated_tx::slab
372+
//// {
373+
//// {},
374+
//// ctx,
375+
//// schema::tx_state::connected,
376+
//// fee,
377+
//// system::possible_narrow_cast<sigs::integer>(sigops)
378+
//// });
379+
//// });
380+
//// // ========================================================================
381+
////}
404382

405383
} // namespace database
406384
} // namespace libbitcoin

include/bitcoin/database/query.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,6 @@ class query
478478
bool set_block_valid(const header_link& link, uint64_t fees) NOEXCEPT;
479479
bool set_block_unconfirmable(const header_link& link) NOEXCEPT;
480480
bool set_block_confirmable(const header_link& link) NOEXCEPT;
481-
482-
// set_txs_connected is FOR PERFORMANCE EVALUATION ONLY.
483-
bool set_txs_connected(const header_link& link) NOEXCEPT;
484-
bool set_tx_preconnected(const tx_link& link, const context& ctx) NOEXCEPT;
485481
bool set_tx_disconnected(const tx_link& link, const context& ctx) NOEXCEPT;
486482
bool set_tx_connected(const tx_link& link, const context& ctx,
487483
uint64_t fee, size_t sigops) NOEXCEPT;

include/bitcoin/database/tables/schema.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ namespace schema
5858
constexpr auto candidate = "candidate";
5959
constexpr auto confirmed = "confirmed";
6060
constexpr auto strong_tx = "strong_tx";
61-
////constexpr auto spent_out = "spent_out";
6261
}
6362

6463
namespace caches
@@ -89,16 +88,15 @@ namespace schema
8988

9089
enum block_state : uint8_t
9190
{
92-
confirmable = 0, // final
93-
valid = 1, // transitional
94-
unconfirmable = 2 // final
91+
confirmable = 0, // final
92+
valid = 1, // transitional
93+
unconfirmable = 2 // final
9594
};
9695

9796
enum tx_state : uint8_t
9897
{
99-
connected = 0, // final
100-
preconnected = 1, // transitional
101-
disconnected = 2 // final
98+
connected = 0, // final
99+
disconnected = 1 // final
102100
};
103101

104102
/// Values.

test/query/validate.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -349,28 +349,6 @@ BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__connected_in_context__tx_conn
349349
BOOST_REQUIRE_EQUAL(sigops, expected_sigops);
350350
}
351351

352-
BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__connected_in_context__tx_preconnected)
353-
{
354-
settings settings{};
355-
settings.path = TEST_DIRECTORY;
356-
test::chunk_store store{ settings };
357-
test::query_accessor query{ store };
358-
BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success);
359-
BOOST_REQUIRE(query.initialize(test::genesis));
360-
BOOST_REQUIRE(query.set(test::block1, context{}, false, false));
361-
BOOST_REQUIRE(query.set(test::block2, context{}, false, false));
362-
BOOST_REQUIRE(query.set(test::block3, context{}, false, false));
363-
364-
uint64_t fee{};
365-
size_t sigops{};
366-
constexpr context ctx{ 7, 8, 9 };
367-
BOOST_REQUIRE(query.set_tx_preconnected(3, ctx));
368-
BOOST_REQUIRE_EQUAL(query.get_tx_state(3, ctx), error::tx_preconnected);
369-
BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 3, ctx), error::tx_preconnected);
370-
BOOST_REQUIRE_EQUAL(fee, 0u);
371-
BOOST_REQUIRE_EQUAL(sigops, 0u);
372-
}
373-
374352
BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__connected_in_context__tx_disconnected)
375353
{
376354
settings settings{};

0 commit comments

Comments
 (0)