Documentation ¶
Index ¶
- Constants
- func CheckMerkleBlock(m msg.MerkleBlock) ([]*common.Uint256, error)
- func HashMerkleBranches(left *common.Uint256, right *common.Uint256) *common.Uint256
- func MakeMerkleParent(left *common.Uint256, right *common.Uint256) (*common.Uint256, error)
- func MurmurHash3(seed uint32, data []byte) uint32
- func NewMerkleBlock(block *types.Block, filter *Filter) (*msg.MerkleBlock, []uint32)
- func NewTxFilter() filter.TxFilter
- type Filter
- func (bf *Filter) Add(data []byte)
- func (bf *Filter) AddHash(hash *common.Uint256)
- func (bf *Filter) AddOutPoint(outpoint *types.OutPoint)
- func (bf *Filter) GetFilterLoadMsg() *msg.FilterLoad
- func (bf *Filter) IsLoaded() bool
- func (bf *Filter) MatchTxAndUpdate(tx *types.Transaction) bool
- func (bf *Filter) Matches(data []byte) bool
- func (bf *Filter) MatchesOutPoint(outpoint *types.OutPoint) bool
- func (bf *Filter) Reload(msg *msg.FilterLoad)
- func (bf *Filter) Unload()
- type MBlock
Constants ¶
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 ¶
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 MurmurHash3 ¶
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 ¶
NewMerkleBlock returns a new *MerkleBlock
func NewTxFilter ¶ added in v0.1.1
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 ¶
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 ¶
Add adds the passed byte slice to the bloom filter.
This function is safe for concurrent access.
func (*Filter) AddHash ¶
AddHash adds the passed chainhash.Hash to the Filter.
This function is safe for concurrent access.
func (*Filter) AddOutPoint ¶
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 ¶
IsLoaded returns true if a filter is loaded, otherwise false.
This function is safe for concurrent access.
func (*Filter) MatchTxAndUpdate ¶
func (bf *Filter) MatchTxAndUpdate(tx *types.Transaction) bool
MatchTxAndUpdate returns true if the bloom filter matches data within the passed tx, otherwise false is returned. If the filter does match the passed tx, it will also update the filter depending on the bloom update flags set via the loaded filter if needed.
This function is safe for concurrent access.
func (*Filter) Matches ¶
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 ¶
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.
type MBlock ¶
type MBlock struct { NumTx uint32 AllHashes []*common.Uint256 FinalHashes []*common.Uint256 MatchedBits []byte Bits []byte }
MBlock is used to house intermediate information needed to generate a MerkleBlock according to a filter.
func (*MBlock) CalcHash ¶
calcHash returns the hash for a sub-tree given a depth-first height and node position.
func (*MBlock) CalcTreeWidth ¶
calcTreeWidth calculates and returns the the number of nodes (width) or a merkle tree at the given depth-first height.
func (*MBlock) TraverseAndBuild ¶
traverseAndBuild builds a partial merkle tree using a recursive depth-first approach. As it calculates the hashes, it also saves whether or not each node is a parent node and a list of final hashes to be included in the merkle block.