From ae74352fc6e254dd00fb8f232058e3a85a8e0fd6 Mon Sep 17 00:00:00 2001 From: Dario Date: Fri, 5 Jun 2020 13:44:41 +0200 Subject: [PATCH] add back const with help of mutable shared mutex --- src/cpp/Crypto/mnemonic.cpp | 2 +- src/cpp/Crypto/mnemonic.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpp/Crypto/mnemonic.cpp b/src/cpp/Crypto/mnemonic.cpp index e9147ae99..bf8d2fd7d 100644 --- a/src/cpp/Crypto/mnemonic.cpp +++ b/src/cpp/Crypto/mnemonic.cpp @@ -153,7 +153,7 @@ int Mnemonic::init(void(*fill_words_func)(unsigned char*), unsigned int original return -5; } -short Mnemonic::getWordIndex(const char* word) +short Mnemonic::getWordIndex(const char* word) const { std::shared_lock _lock(mWorkingMutex); DHASH word_hash = DRMakeStringHash(word); diff --git a/src/cpp/Crypto/mnemonic.h b/src/cpp/Crypto/mnemonic.h index afc708ac1..7d9a848b7 100644 --- a/src/cpp/Crypto/mnemonic.h +++ b/src/cpp/Crypto/mnemonic.h @@ -30,13 +30,13 @@ public: int init(void(*fill_words_func)(unsigned char*), unsigned int original_size, unsigned int compressed_size); - inline const char* getWord(short index) { + inline const char* getWord(short index) const { std::shared_lock _lock(mWorkingMutex); if (index < 2048 && index >= 0) return mWords[index]; return nullptr; } - short getWordIndex(const char* word); - inline bool isWordExist(const std::string& word) { + short getWordIndex(const char* word) const; + inline bool isWordExist(const std::string& word) const { std::shared_lock _lock(mWorkingMutex); return getWordIndex(word.data()) != -1; } @@ -62,7 +62,7 @@ protected: typedef std::pair HashCollideWordEntry; std::map mWordHashIndices; std::map> mHashCollisionWords; - std::shared_mutex mWorkingMutex; + mutable std::shared_mutex mWorkingMutex; };