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 *util.Block, filter *Filter) (*msg.MerkleBlock, []uint32)
- type Filter
- func (bf *Filter) Add(data []byte)
- func (bf *Filter) AddHash(hash *common.Uint256)
- func (bf *Filter) AddOutPoint(outpoint *util.OutPoint)
- func (bf *Filter) GetFilterLoadMsg() *msg.FilterLoad
- func (bf *Filter) IsLoaded() bool
- func (bf *Filter) Matches(data []byte) bool
- func (bf *Filter) MatchesOutPoint(outpoint *util.OutPoint) bool
- func (bf *Filter) Reload(msg *msg.FilterLoad)
- func (bf *Filter) ToTxFilterMsg(typ uint8) *msg.TxFilterLoad
- func (bf *Filter) Unload()
- type MerkleBranch
- type MerkleProof
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
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) 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.
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.
type MerkleBranch ¶
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