diff --git a/libwhisper/BloomFilter.h b/libwhisper/BloomFilter.h index 32ac15043..02cc80505 100644 --- a/libwhisper/BloomFilter.h +++ b/libwhisper/BloomFilter.h @@ -88,7 +88,7 @@ template bool TopicBloomFilterBase::isBitSet(FixedHash const& _h, unsigned _index) { unsigned iByte = _index / 8; - unsigned iBit = _index & 0x7; + unsigned iBit = _index % 8; return (_h[iByte] & c_powerOfTwoBitMmask[iBit]) != 0; } @@ -96,7 +96,7 @@ template void TopicBloomFilterBase::setBit(FixedHash& _h, unsigned _index) { unsigned iByte = _index / 8; - unsigned iBit = _index & 0x7; + unsigned iBit = _index % 8; _h[iByte] |= c_powerOfTwoBitMmask[iBit]; } diff --git a/libwhisper/Message.cpp b/libwhisper/Message.cpp index 435811a3b..dd72ff734 100644 --- a/libwhisper/Message.cpp +++ b/libwhisper/Message.cpp @@ -170,7 +170,7 @@ void Envelope::proveWork(unsigned _ms) chrono::high_resolution_clock::time_point then = chrono::high_resolution_clock::now() + chrono::milliseconds(_ms); while (chrono::high_resolution_clock::now() < then) // do it rounds of 1024 for efficiency - for (unsigned i = 0; i < 1024; ++i) + for (unsigned i = 0; i < 1024; ++i, ++d[1]) { auto fbs = dev::sha3(chuck).firstBitSet(); if (fbs > bestBitSet) @@ -178,8 +178,6 @@ void Envelope::proveWork(unsigned _ms) bestBitSet = fbs; m_nonce = (h256::Arith)d[1]; } - - incrementHash(d[1]); } } diff --git a/libwhisper/Message.h b/libwhisper/Message.h index fb89576e9..ae61f210a 100644 --- a/libwhisper/Message.h +++ b/libwhisper/Message.h @@ -81,7 +81,6 @@ public: void proveWork(unsigned _ms); bool matchesBloomFilter(TopicBloomFilterHash const& f) const; - static void incrementHash(h256& _h) { for (unsigned i = h256::size; i > 0 && !++_h[--i]; ) {} } private: Envelope(unsigned _exp, unsigned _ttl, AbridgedTopics const& _topic): m_expiry(_exp), m_ttl(_ttl), m_topic(_topic) {}