/// <summary>
        /// Tests if the address AND all of the topics are matched by the filter.
        /// </summary>
        /// <param name="bloom">The filter to match.</param>
        /// <param name="addresses">The addresses to match against the filter.</param>
        /// <param name="topics">The topics to match against the filter.</param>
        /// <returns>True if all of the filter parameters match.</returns>
        public static bool Test(this Bloom bloom, IEnumerable <uint160> addresses, IEnumerable <byte[]> topics)
        {
            var filterBloom = new Bloom();

            if (addresses != null)
            {
                foreach (uint160 address in addresses)
                {
                    if (address != null)
                    {
                        filterBloom.Add(address.ToBytes());
                    }
                }
            }

            if (topics != null)
            {
                foreach (byte[] topic in topics)
                {
                    if (topic != null)
                    {
                        filterBloom.Add(topic);
                    }
                }
            }

            return(bloom.Test(filterBloom));
        }
예제 #2
0
        /// <summary>
        /// Determine whether some input is possibly contained within the filter.
        /// </summary>
        /// <param name="test">The byte array to test.</param>
        /// <returns>Whether this data could be contained within the filter.</returns>
        public bool Test(byte[] test)
        {
            var compare = new Bloom();

            compare.Add(test);
            return(this.Test(compare));
        }