OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
index_comparator.cpp
Go to the documentation of this file.
1
// Copyright (c) 2021 MIT Digital Currency Initiative,
2
// Federal Reserve Bank of Boston
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include "
index_comparator.hpp
"
7
8
#include <cstdint>
9
#include <cstring>
10
#include <leveldb/slice.h>
11
12
namespace
cbdc::raft
{
13
auto
index_comparator::Compare
(
const
leveldb::Slice& a,
14
const
leveldb::Slice& b)
const
->
int
{
15
assert(a.size() == b.size());
16
uint64_t a_val{0};
17
uint64_t b_val{0};
18
std::memcpy(&a_val, a.data(),
sizeof
(a_val));
19
std::memcpy(&b_val, b.data(),
sizeof
(b_val));
20
if
(a_val == b_val) {
21
return
0;
22
}
23
24
if
(a_val < b_val) {
25
return
-1;
26
}
27
28
return
1;
29
}
30
31
auto
index_comparator::Name
() const -> const
char
* {
32
return
"IndexComparator"
;
33
}
34
35
void
index_comparator::FindShortestSeparator
(
36
std::string*
/* start */
,
37
const
leveldb::Slice&
/* limit */
)
const
{}
38
39
void
index_comparator::FindShortSuccessor
(std::string*
/* key */
)
const
{}
40
}
cbdc::raft::index_comparator::FindShortestSeparator
void FindShortestSeparator(std::string *, const leveldb::Slice &) const override
Not implemented.
Definition
index_comparator.cpp:35
cbdc::raft::index_comparator::FindShortSuccessor
void FindShortSuccessor(std::string *) const override
Not implemented.
Definition
index_comparator.cpp:39
cbdc::raft::index_comparator::Compare
auto Compare(const leveldb::Slice &a, const leveldb::Slice &b) const -> int override
Compare the order of the two given LevelDB keys when converted to uint64_t.
Definition
index_comparator.cpp:13
cbdc::raft::index_comparator::Name
auto Name() const -> const char *override
Return the comparator name.
Definition
index_comparator.cpp:31
index_comparator.hpp
cbdc::raft
Definition
console_logger.cpp:8
src
util
raft
index_comparator.cpp
Generated by
1.12.0