Created
June 15, 2022 15:17
-
-
Save stoffu/0af118aa27a55831d677c6c5a61324b1 to your computer and use it in GitHub Desktop.
base58: empty all functions except for static object instancing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- base58.cpp 2022-06-09 09:57:03.000000000 +0900 | |
+++ base58.new.cpp 2022-06-16 00:15:38.000000000 +0900 | |
@@ -56,6 +56,7 @@ | |
{ | |
reverse_alphabet() | |
{ | |
+#if 0 | |
m_data.resize(alphabet[alphabet_size - 1] - alphabet[0] + 1, -1); | |
for (size_t i = 0; i < alphabet_size; ++i) | |
@@ -63,12 +64,16 @@ | |
size_t idx = static_cast<size_t>(alphabet[i] - alphabet[0]); | |
m_data[idx] = static_cast<int8_t>(i); | |
} | |
+#endif | |
} | |
int operator()(char letter) const | |
{ | |
+ return 0; | |
+#if 0 | |
size_t idx = static_cast<size_t>(letter - alphabet[0]); | |
return idx < m_data.size() ? m_data[idx] : -1; | |
+#endif | |
} | |
static reverse_alphabet instance; | |
@@ -83,17 +88,22 @@ | |
{ | |
decoded_block_sizes() | |
{ | |
+#if 0 | |
m_data.resize(encoded_block_sizes[full_block_size] + 1, -1); | |
for (size_t i = 0; i <= full_block_size; ++i) | |
{ | |
m_data[encoded_block_sizes[i]] = static_cast<int>(i); | |
} | |
+#endif | |
} | |
int operator()(size_t encoded_block_size) const | |
{ | |
+ return 0; | |
+#if 0 | |
assert(encoded_block_size <= full_encoded_block_size); | |
return m_data[encoded_block_size]; | |
+#endif | |
} | |
static decoded_block_sizes instance; | |
@@ -106,6 +116,8 @@ | |
uint64_t uint_8be_to_64(const uint8_t* data, size_t size) | |
{ | |
+ return 0; | |
+#if 0 | |
assert(1 <= size && size <= sizeof(uint64_t)); | |
uint64_t res = 0; | |
@@ -123,18 +135,22 @@ | |
} | |
return res; | |
+#endif | |
} | |
void uint_64_to_8be(uint64_t num, size_t size, uint8_t* data) | |
{ | |
+#if 0 | |
assert(1 <= size && size <= sizeof(uint64_t)); | |
uint64_t num_be = SWAP64BE(num); | |
memcpy(data, reinterpret_cast<uint8_t*>(&num_be) + sizeof(uint64_t) - size, size); | |
+#endif | |
} | |
void encode_block(const char* block, size_t size, char* res) | |
{ | |
+#if 0 | |
assert(1 <= size && size <= full_block_size); | |
uint64_t num = uint_8be_to_64(reinterpret_cast<const uint8_t*>(block), size); | |
@@ -146,10 +162,12 @@ | |
res[i] = alphabet[remainder]; | |
--i; | |
} | |
+#endif | |
} | |
bool decode_block(const char* block, size_t size, char* res) | |
{ | |
+#if 0 | |
assert(1 <= size && size <= full_encoded_block_size); | |
int res_size = decoded_block_sizes::instance(size); | |
@@ -177,6 +195,7 @@ | |
return false; // Overflow | |
uint_64_to_8be(res_num, res_size, reinterpret_cast<uint8_t*>(res)); | |
+#endif | |
return true; | |
} | |
@@ -184,6 +203,8 @@ | |
std::string encode(const std::string& data) | |
{ | |
+ return ""; | |
+#if 0 | |
if (data.empty()) | |
return std::string(); | |
@@ -203,10 +224,12 @@ | |
} | |
return res; | |
+#endif | |
} | |
bool decode(const std::string& enc, std::string& data) | |
{ | |
+#if 0 | |
if (enc.empty()) | |
{ | |
data.clear(); | |
@@ -233,22 +256,27 @@ | |
&data[full_block_count * full_block_size])) | |
return false; | |
} | |
+#endif | |
return true; | |
} | |
std::string encode_addr(uint64_t tag, const std::string& data) | |
{ | |
+ return ""; | |
+#if 0 | |
std::string buf = get_varint_data(tag); | |
buf += data; | |
crypto::hash hash = crypto::cn_fast_hash(buf.data(), buf.size()); | |
const char* hash_data = reinterpret_cast<const char*>(&hash); | |
buf.append(hash_data, addr_checksum_size); | |
return encode(buf); | |
+#endif | |
} | |
bool decode_addr(std::string addr, uint64_t& tag, std::string& data) | |
{ | |
+#if 0 | |
std::string addr_data; | |
bool r = decode(addr, addr_data); | |
if (!r) return false; | |
@@ -266,6 +294,7 @@ | |
if (read <= 0) return false; | |
data = addr_data.substr(read); | |
+#endif | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment