aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorjeffro256 <jeffro256@tutanota.com>2025-11-21 14:40:48 -0600
committerjeffro256 <jeffro256@tutanota.com>2026-02-24 17:39:20 -0600
commit1e6a55109f4434b166a35a26123d7a4370a507b7 (patch)
tree2891b056f8462ea2ac7b4c1ee081c6984aa13352 /src/common
parentdbcc7d212c094bd1a45f7291dbb99a4b4627a96d (diff)
downloadmonzero-core-1e6a55109f4434b166a35a26123d7a4370a507b7.tar.gz
monzero-core-1e6a55109f4434b166a35a26123d7a4370a507b7.tar.xz
monzero-core-1e6a55109f4434b166a35a26123d7a4370a507b7.zip
cryptonote_basic: fix add_extra_nonce_to_tx_extra() length
Missing unit tests.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/varint.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/varint.h b/src/common/varint.h
index 9f8b9a4ab..d544e198a 100644
--- a/src/common/varint.h
+++ b/src/common/varint.h
@@ -125,4 +125,14 @@ namespace tools {
int read_varint(InputIt &&first, InputIt &&last, T &i) {
return read_varint<std::numeric_limits<T>::digits>(std::forward<InputIt>(first), std::forward<InputIt>(last), i);
}
+
+ template <typename T, typename = std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value>>
+ constexpr std::size_t get_varint_byte_size(T val) {
+ std::size_t bytes = 0;
+ do {
+ ++bytes;
+ val >>= 7;
+ } while (val);
+ return bytes;
+ }
}