func NewFilter(elements, tweak uint32, fprate float64) *Filter {
	if fprate > 1.0 {
		fprate = 1.0
	}
	if fprate < 1e-9 {
		fprate = 1e-9
	}
	dataLen := uint32(-1 * float64(elements) * math.Log(fprate) / ln2Squared)
	dataLen = minUint32(dataLen, MaxFilterLoadFilterSize*8) / 8
	hashFuncs := uint32(float64(dataLen*8) / float64(elements) * math.Ln2)
	hashFuncs = minUint32(hashFuncs, MaxFilterLoadHashFuncs)
	msg := &msg.FilterLoad{
		Filter:    make([]byte, dataLen),
		HashFuncs: hashFuncs,
		Tweak:     tweak,
	}
	return &Filter{msg: msg}
}
NewFilter creates a new bloom filter instance, mainly to be used by SPV
clients.  The tweak parameter is a random value added to the seed value.
The false positive rate is the probability of a false positive where 1.0 is
"match everything" and zero is unachievable.  Thus, providing any false
positive rates less than 0 or greater than 1 will be adjusted to the valid
range.

For more information on what values to use for both elements and fprate,
see https://en.wikipedia.org/wiki/Bloom_filter.
package bloom
import (
	"math"
	"sync"
	"github.com/elastos/Elastos.ELA.SideChain/types"
	"github.com/elastos/Elastos.ELA/common"
	"github.com/elastos/Elastos.ELA/p2p/msg"
)
const (
	MaxFilterLoadHashFuncs = 50
	MaxFilterLoadFilterSize = 36000
)
const ln2Squared = math.Ln2 * math.Ln2
func minUint32(a, b uint32) uint32 {
	if a < b {
		return a
	}
	return b
}
type Filter struct {
	mtx sync.Mutex
	msg *msg.FilterLoad
}