bloom

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxFilterLoadHashFuncs is the maximum number of hash functions to
	// load into the Bloom filter.
	MaxFilterLoadHashFuncs = 50

	// MaxFilterLoadFilterSize is the maximum size in bytes a filter may be.
	MaxFilterLoadFilterSize = 36000
)

Variables

This section is empty.

Functions

func CheckMerkleBlock

func CheckMerkleBlock(m msg.MerkleBlock) ([]*common.Uint256, error)

take in a merkle block, parse through it, and return txids indicated If there's any problem return an error. Checks self-consistency only. doing it with a stack instead of recursion. Because... OK I don't know why I'm just not in to recursion OK?

func HashMerkleBranches

func HashMerkleBranches(left *common.Uint256, right *common.Uint256) *common.Uint256

HashMerkleBranches takes two hashes, treated as the left and right tree nodes, and returns the hash of their concatenation. This is a helper function used to aid in the generation of a merkle tree.

func MakeMerkleParent

func MakeMerkleParent(left *common.Uint256, right *common.Uint256) (*common.Uint256, error)

func MurmurHash3

func MurmurHash3(seed uint32, data []byte) uint32

MurmurHash3 implements a non-cryptographic hash function using the MurmurHash3 algorithm. This implementation yields a 32-bit hash value which is suitable for general hash-based lookups. The seed can be used to effectively randomize the hash function. This makes it ideal for use in bloom filters which need multiple independent hash functions.

func NewMerkleBlock

func NewMerkleBlock(block *util.Block, filter *Filter) (*msg.MerkleBlock, []uint32)

NewMerkleBlock returns a new *MerkleBlock

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter defines a bitcoin bloom filter that provides easy manipulation of raw filter data.

func LoadFilter

func LoadFilter(msg *msg.FilterLoad) *Filter

LoadFilter creates a new Filter instance with the given underlying msg.FilterLoad.

func NewFilter

func NewFilter(elements, tweak uint32, fprate float64) *Filter

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.

func (*Filter) Add

func (bf *Filter) Add(data []byte)

Add adds the passed byte slice to the bloom filter.

This function is safe for concurrent access.

func (*Filter) AddHash

func (bf *Filter) AddHash(hash *common.Uint256)

AddHash adds the passed chainhash.Hash to the Filter.

This function is safe for concurrent access.

func (*Filter) AddOutPoint

func (bf *Filter) AddOutPoint(outpoint *util.OutPoint)

AddOutPoint adds the passed tx outpoint to the bloom filter.

This function is safe for concurrent access.

func (*Filter) GetFilterLoadMsg

func (bf *Filter) GetFilterLoadMsg() *msg.FilterLoad

func (*Filter) IsLoaded

func (bf *Filter) IsLoaded() bool

IsLoaded returns true if a filter is loaded, otherwise false.

This function is safe for concurrent access.

func (*Filter) Matches

func (bf *Filter) Matches(data []byte) bool

Matches returns true if the bloom filter might contain the passed data and false if it definitely does not.

This function is safe for concurrent access.

func (*Filter) MatchesOutPoint

func (bf *Filter) MatchesOutPoint(outpoint *util.OutPoint) bool

MatchesOutPoint returns true if the bloom filter might contain the passed outpoint and false if it definitely does not.

This function is safe for concurrent access.

func (*Filter) Reload

func (bf *Filter) Reload(msg *msg.FilterLoad)

Reload loads a new filter replacing any existing filter.

This function is safe for concurrent access.

func (*Filter) ToTxFilterMsg added in v0.0.2

func (bf *Filter) ToTxFilterMsg(typ uint8) *msg.TxFilterLoad

ToTxFilterMsg parse the bloom filter into a *msg.TxFilterLoad instance.

func (*Filter) Unload

func (bf *Filter) Unload()

Unload unloads the bloom filter.

This function is safe for concurrent access.

type MerkleBranch

type MerkleBranch struct {
	Branches []common.Uint256
	Index    int
}

func GetTxMerkleBranch

func GetTxMerkleBranch(msg msg.MerkleBlock, txId *common.Uint256) (*MerkleBranch, error)

type MerkleProof

type MerkleProof struct {
	BlockHash    common.Uint256
	Height       uint32
	Transactions uint32
	Hashes       []*common.Uint256
	Flags        []byte
}

func (*MerkleProof) Deserialize

func (p *MerkleProof) Deserialize(r io.Reader) error

func (*MerkleProof) Serialize

func (p *MerkleProof) Serialize(w io.Writer) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL