Browse Source

Fix for log blooms.

cl-refactor
Gav Wood 10 years ago
parent
commit
3b786cf004
  1. 14
      libdevcore/FixedHash.h

14
libdevcore/FixedHash.h

@ -158,21 +158,25 @@ public:
return ret; return ret;
} }
template <unsigned P, unsigned M> inline FixedHash& shiftBloom(FixedHash<M> const& _h) { return (*this |= _h.template nbloom<P, N>()); } template <unsigned P, unsigned M> inline FixedHash& shiftBloom(FixedHash<M> const& _h)
{
return (*this |= _h.template nbloom<P, N>());
}
template <unsigned P, unsigned M> inline FixedHash<M> nbloom() const template <unsigned P, unsigned M> inline FixedHash<M> nbloom() const
{ {
static const unsigned c_bloomBytes = (M + 7) / 8; static const unsigned c_bloomBits = M * 8;
unsigned mask = (1 << c_bloomBytes) - 1; unsigned mask = c_bloomBits - 1;
unsigned bloomBytes = (dev::toLog2(c_bloomBits) + 7) / 8;
FixedHash<M> ret; FixedHash<M> ret;
byte const* p = data(); byte const* p = data();
for (unsigned i = 0; i < P; ++i) for (unsigned i = 0; i < P; ++i)
{ {
unsigned index = 0; unsigned index = 0;
for (unsigned j = 0; j < c_bloomBytes; ++j, ++p) for (unsigned j = 0; j < bloomBytes; ++j, ++p)
index = (index << 8) | *p; index = (index << 8) | *p;
index &= mask; index &= mask;
ret[N - 1 - index / 8] |= (1 << (index % 8)); ret[M - 1 - index / 8] |= (1 << (index % 8));
} }
return ret; return ret;
} }

Loading…
Cancel
Save