14
14
#include < windows.h>
15
15
// clang-format on
16
16
#include < codecvt>
17
- #include < shellapi.h>
18
17
#include < locale>
18
+ #include < shellapi.h>
19
19
#endif
20
20
21
21
using namespace btck ;
22
22
23
- std::vector<unsigned char > hex_string_to_char_vec (std::string_view hex)
23
+ std::vector<std::byte> hex_string_to_byte_vec (std::string_view hex)
24
24
{
25
- std::vector<unsigned char > bytes;
25
+ std::vector<std::byte > bytes;
26
26
bytes.reserve (hex.length () / 2 );
27
27
28
28
for (size_t i{0 }; i < hex.length (); i += 2 ) {
29
- unsigned char byte;
30
- auto [ptr, ec] = std::from_chars (hex.data () + i, hex.data () + i + 2 , byte, 16 );
31
- if (ec == std::errc{} && ptr == hex.data () + i + 2 ) {
32
- bytes.push_back (byte);
29
+ uint8_t byte_value;
30
+ auto [ptr, ec] = std::from_chars (hex.data () + i, hex.data () + i + 2 , byte_value, 16 );
31
+
32
+ if (ec != std::errc{} || ptr != hex.data () + i + 2 ) {
33
+ throw std::invalid_argument (" Invalid hex character" );
33
34
}
35
+ bytes.push_back (static_cast <std::byte>(byte_value));
34
36
}
35
37
return bytes;
36
38
}
@@ -47,7 +49,7 @@ class KernelLog
47
49
class TestValidationInterface : public ValidationInterface <TestValidationInterface>
48
50
{
49
51
public:
50
- TestValidationInterface () : ValidationInterface() {}
52
+ TestValidationInterface () = default ;
51
53
52
54
std::optional<std::string> m_expected_valid_block = std::nullopt;
53
55
@@ -104,7 +106,7 @@ class TestValidationInterface : public ValidationInterface<TestValidationInterfa
104
106
class TestKernelNotifications : public KernelNotifications <TestKernelNotifications>
105
107
{
106
108
public:
107
- void BlockTipHandler (btck_SynchronizationState, const btck_BlockIndex* , double ) override
109
+ void BlockTipHandler (btck_SynchronizationState, const BlockTreeEntry , double ) override
108
110
{
109
111
std::cout << " Block tip changed" << std::endl;
110
112
}
@@ -206,7 +208,7 @@ int main(int argc, char* argv[])
206
208
continue ;
207
209
}
208
210
209
- auto raw_block{hex_string_to_char_vec (line)};
211
+ auto raw_block{hex_string_to_byte_vec (line)};
210
212
std::unique_ptr<Block> block;
211
213
try {
212
214
block = std::make_unique<Block>(raw_block);
0 commit comments