Пример #1
0
        private static Bloom.BloomExtract GetExtract(Span <byte> sequence)
        {
            int GetIndex(Span <byte> bytes, int index1, int index2)
            {
                return(2047 - ((bytes[index1] << 8) + bytes[index2]) % 2048);
            }

            var keccakBytes = ValueKeccak.Compute(sequence).BytesAsSpan;
            var indexes     = new Bloom.BloomExtract(GetIndex(keccakBytes, 0, 1), GetIndex(keccakBytes, 2, 3), GetIndex(keccakBytes, 4, 5));

            return(indexes);
        }
Пример #2
0
 private void Set(Span <byte> sequence, Bloom?masterBloom = null)
 {
     Bloom.BloomExtract indexes = GetExtract(sequence);
     Set(indexes.Index1);
     Set(indexes.Index2);
     Set(indexes.Index3);
     if (masterBloom != null)
     {
         masterBloom.Set(indexes.Index1);
         masterBloom.Set(indexes.Index2);
         masterBloom.Set(indexes.Index3);
     }
 }
Пример #3
0
 public bool Matches(Bloom.BloomExtract extract) => Matches(ref extract);
Пример #4
0
 public bool Matches(ref Bloom.BloomExtract extract) => Get(extract.Index1) && Get(extract.Index2) && Get(extract.Index3);
Пример #5
0
 public bool Matches(byte[] sequence)
 {
     Bloom.BloomExtract indexes = GetExtract(sequence);
     return(Matches(ref indexes));
 }