Skip to content

Commit c74548a

Browse files
Remove duplicate ccf::kv::TxID type (#7477)
Co-authored-by: cjen1-msft <chrisjensen@microsoft.com>
1 parent 3407244 commit c74548a

23 files changed

Lines changed: 133 additions & 174 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
### Changed
1313

1414
- Start nodes now confirm that read-only ledger directories are empty on startup (#7355).
15+
- In the C++ API, the method `get_txid()` on `ccf::kv::ReadOnlyStore` has been renamed to `current_txid()`. This may affect historical query code which works directly with the returned `StorePtr` (#7477).
1516

1617
## [7.0.0-dev5]
1718

include/ccf/kv/read_only_store.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ccf::kv
1414
public:
1515
virtual ~ReadOnlyStore() = default;
1616

17-
virtual ccf::TxID get_txid() = 0;
17+
virtual ccf::TxID current_txid() = 0;
1818
virtual ccf::kv::ReadOnlyTx create_read_only_tx() = 0;
1919
virtual std::unique_ptr<ccf::kv::ReadOnlyTx> create_read_only_tx_ptr() = 0;
2020
virtual ccf::kv::TxDiff create_tx_diff() = 0;

samples/apps/logging/logging.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ namespace loggingapp
17211721
if (v.has_value())
17221722
{
17231723
LoggingGetHistoricalRange::Entry e;
1724-
e.seqno = store->get_txid().seqno;
1724+
e.seqno = store->current_txid().seqno;
17251725
e.id = id;
17261726
e.msg = v.value();
17271727
response.entries.push_back(e);
@@ -1905,7 +1905,7 @@ namespace loggingapp
19051905
if (v.has_value())
19061906
{
19071907
LoggingGetHistoricalRange::Entry e;
1908-
e.seqno = store->get_txid().seqno;
1908+
e.seqno = store->current_txid().seqno;
19091909
e.id = id;
19101910
e.msg = v.value();
19111911
response.entries.push_back(e);

src/consensus/aft/raft.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ namespace aft
13251325
return;
13261326
}
13271327

1328-
ccf::kv::TxID expected{r.term_of_idx, i};
1328+
ccf::TxID expected{r.term_of_idx, i};
13291329
auto ds = store->deserialize(entry, public_only, expected);
13301330
if (ds == nullptr)
13311331
{

src/consensus/aft/raft_types.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ namespace aft
3535
virtual ~Store() {}
3636
virtual void compact(Index v) = 0;
3737
virtual void rollback(
38-
const ccf::kv::TxID& tx_id, Term term_of_next_version) = 0;
38+
const ccf::TxID& tx_id, Term term_of_next_version) = 0;
3939
virtual void initialise_term(Term t) = 0;
4040
virtual std::unique_ptr<ccf::kv::AbstractExecutionWrapper> deserialize(
4141
const std::vector<uint8_t> data,
4242
bool public_only = false,
43-
const std::optional<ccf::kv::TxID>& expected_txid = std::nullopt) = 0;
43+
const std::optional<ccf::TxID>& expected_txid = std::nullopt) = 0;
4444
};
4545

4646
template <typename T>
@@ -61,8 +61,7 @@ namespace aft
6161
}
6262
}
6363

64-
void rollback(
65-
const ccf::kv::TxID& tx_id, Term term_of_next_version) override
64+
void rollback(const ccf::TxID& tx_id, Term term_of_next_version) override
6665
{
6766
auto p = x.lock();
6867
if (p)
@@ -83,7 +82,7 @@ namespace aft
8382
std::unique_ptr<ccf::kv::AbstractExecutionWrapper> deserialize(
8483
const std::vector<uint8_t> data,
8584
bool public_only = false,
86-
const std::optional<ccf::kv::TxID>& expected_txid = std::nullopt) override
85+
const std::optional<ccf::TxID>& expected_txid = std::nullopt) override
8786
{
8887
auto p = x.lock();
8988
if (p)

src/consensus/aft/test/driver.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ struct LoggingStubStore_Mermaid : public aft::LoggingStubStoreConfig
7979
aft::LoggingStubStoreConfig::compact(idx);
8080
}
8181

82-
void rollback(const ccf::kv::TxID& tx_id, aft::Term t) override
82+
void rollback(const ccf::TxID& tx_id, aft::Term t) override
8383
{
8484
RAFT_DRIVER_PRINT(
8585
"{}->>{}: [KV] rolling back to {}.{}, in term {}",
8686
_id,
8787
_id,
88-
tx_id.term,
89-
tx_id.version,
88+
tx_id.view,
89+
tx_id.seqno,
9090
t);
9191
aft::LoggingStubStoreConfig::rollback(tx_id, t);
9292
}

src/consensus/aft/test/logging_stub.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ namespace aft
349349

350350
virtual void compact(Index i) {}
351351

352-
virtual void rollback(const ccf::kv::TxID& tx_id, Term t) {}
352+
virtual void rollback(const ccf::TxID& tx_id, Term t) {}
353353

354354
virtual void initialise_term(Term t) {}
355355

@@ -373,7 +373,7 @@ namespace aft
373373
public:
374374
ExecutionWrapper(
375375
const std::vector<uint8_t>& data_,
376-
const std::optional<ccf::kv::TxID>& expected_txid,
376+
const std::optional<ccf::TxID>& expected_txid,
377377
ccf::kv::ConsensusHookPtrs&& hooks_) :
378378
hooks(std::move(hooks_))
379379
{
@@ -390,7 +390,7 @@ namespace aft
390390

391391
if (expected_txid.has_value())
392392
{
393-
if (term != expected_txid->term || index != expected_txid->version)
393+
if (term != expected_txid->view || index != expected_txid->seqno)
394394
{
395395
result = ccf::kv::ApplyResult::FAIL;
396396
}
@@ -452,7 +452,7 @@ namespace aft
452452
virtual std::unique_ptr<ccf::kv::AbstractExecutionWrapper> deserialize(
453453
const std::vector<uint8_t>& data,
454454
bool public_only = false,
455-
const std::optional<ccf::kv::TxID>& expected_txid = std::nullopt)
455+
const std::optional<ccf::TxID>& expected_txid = std::nullopt)
456456
{
457457
ccf::kv::ConsensusHookPtrs hooks = {};
458458
return std::make_unique<ExecutionWrapper>(
@@ -504,20 +504,20 @@ namespace aft
504504
retired_committed_entries.end());
505505
}
506506

507-
virtual void rollback(const ccf::kv::TxID& tx_id, Term t) override
507+
virtual void rollback(const ccf::TxID& tx_id, Term t) override
508508
{
509509
retired_committed_entries.erase(
510510
std::remove_if(
511511
retired_committed_entries.begin(),
512512
retired_committed_entries.end(),
513-
[tx_id](const auto& entry) { return entry.first > tx_id.version; }),
513+
[tx_id](const auto& entry) { return entry.first > tx_id.seqno; }),
514514
retired_committed_entries.end());
515515
}
516516

517517
virtual std::unique_ptr<ccf::kv::AbstractExecutionWrapper> deserialize(
518518
const std::vector<uint8_t>& data,
519519
bool public_only = false,
520-
const std::optional<ccf::kv::TxID>& expected_txid = std::nullopt) override
520+
const std::optional<ccf::TxID>& expected_txid = std::nullopt) override
521521
{
522522
// Set reconfiguration hook if there are any new nodes
523523
// Read wrapping term and version

src/indexing/indexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace ccf::indexing
110110
auto stores = transaction_fetcher->fetch_transactions(seqnos);
111111
for (auto& store : stores)
112112
{
113-
const ccf::TxID tx_id = store->get_txid();
113+
const ccf::TxID tx_id = store->current_txid();
114114

115115
for (auto& strategy : strategies)
116116
{

src/indexing/test/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static inline bool create_transactions(
191191
return false;
192192
}
193193

194-
const auto seqno = tx.get_txid()->version;
194+
const auto seqno = tx.get_txid()->seqno;
195195

196196
for (auto p_exp : modified)
197197
{

src/indexing/test/indexing.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ TEST_CASE("basic indexing" * doctest::test_suite("indexing"))
227227
REQUIRE(indexer.install_strategy(index_b));
228228
REQUIRE_FALSE(indexer.install_strategy(index_b));
229229

230-
auto current_ = kv_store.current_txid();
231-
ccf::TxID current{current_.term, current_.version};
230+
ccf::TxID current = kv_store.current_txid();
232231
REQUIRE(index_a->get_indexed_watermark() == current);
233232
REQUIRE(index_b->get_indexed_watermark() == ccf::TxID());
234233

@@ -832,7 +831,7 @@ TEST_CASE(
832831

833832
while (true)
834833
{
835-
const auto end_seqno = kv_store.get_txid().seqno;
834+
const auto end_seqno = kv_store.current_txid().seqno;
836835
const auto range_end = std::min(end_seqno, range_start + max_range);
837836

838837
auto results =

0 commit comments

Comments
 (0)