P2P: save/load onion peers, added onion seed nodes
This commit is contained in:
+43
@@ -400,6 +400,49 @@ FORCEINLINE void secure_zero_memory(T& value)
|
||||
std::string to_onion_v3(const hash& pubkey);
|
||||
hash from_onion_v3(const std::string& address);
|
||||
|
||||
static FORCEINLINE constexpr hash from_onion_v3_const(const char* address)
|
||||
{
|
||||
uint8_t buf[HASH_SIZE + 4] = {};
|
||||
uint8_t* p = buf;
|
||||
|
||||
uint64_t data = 0;
|
||||
uint64_t bit_size = 0;
|
||||
|
||||
for (size_t i = 0; i < 56; ++i) {
|
||||
const char c = address[i];
|
||||
uint64_t digit = 0;
|
||||
|
||||
if ('a' <= c && c <= 'z') {
|
||||
digit = static_cast<uint64_t>(c - 'a');
|
||||
}
|
||||
else if ('A' <= c && c <= 'Z') {
|
||||
digit = static_cast<uint64_t>(c - 'A');
|
||||
}
|
||||
else if ('2' <= c && c <= '7') {
|
||||
digit = static_cast<uint64_t>(c - '2') + 26;
|
||||
}
|
||||
else {
|
||||
return {};
|
||||
}
|
||||
|
||||
data = (data << 5) | digit;
|
||||
bit_size += 5;
|
||||
|
||||
while (bit_size >= 8) {
|
||||
bit_size -= 8;
|
||||
*(p++) = static_cast<uint8_t>(data >> bit_size);
|
||||
}
|
||||
}
|
||||
|
||||
hash result;
|
||||
|
||||
for (size_t i = 0; i < HASH_SIZE; ++i) {
|
||||
result.h[i] = buf[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
void memory_tracking_start();
|
||||
|
||||
Reference in New Issue
Block a user