Browse Source

Merge pull request #2421 from gluk256/_operator++

FixedHash::operator++() utilized
cl-refactor
Gav Wood 10 years ago
parent
commit
2c1276ab37
  1. 4
      libwhisper/BloomFilter.h
  2. 4
      libwhisper/Message.cpp
  3. 1
      libwhisper/Message.h

4
libwhisper/BloomFilter.h

@ -88,7 +88,7 @@ template <unsigned N>
bool TopicBloomFilterBase<N>::isBitSet(FixedHash<N> 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 <unsigned N>
void TopicBloomFilterBase<N>::setBit(FixedHash<N>& _h, unsigned _index)
{
unsigned iByte = _index / 8;
unsigned iBit = _index & 0x7;
unsigned iBit = _index % 8;
_h[iByte] |= c_powerOfTwoBitMmask[iBit];
}

4
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]);
}
}

1
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) {}

Loading…
Cancel
Save