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); }
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); } }
public bool Matches(Bloom.BloomExtract extract) => Matches(ref extract);
public bool Matches(ref Bloom.BloomExtract extract) => Get(extract.Index1) && Get(extract.Index2) && Get(extract.Index3);
public bool Matches(byte[] sequence) { Bloom.BloomExtract indexes = GetExtract(sequence); return(Matches(ref indexes)); }