Documentation ¶
Index ¶
- Constants
- func BuildBasicFilter(block *wire.MsgBlock) (*gcs.Filter, error)
- func BuildExtFilter(block *wire.MsgBlock) (*gcs.Filter, error)
- func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte
- func GetFilterHash(filter *gcs.Filter) chainhash.Hash
- func MakeHeaderForFilter(filter *gcs.Filter, prevHeader chainhash.Hash) chainhash.Hash
- func OutPointToFilterEntry(outpoint wire.OutPoint) []byte
- func RandomKey() ([gcs.KeySize]byte, error)
- type GCSBuilder
- func WithKey(key [gcs.KeySize]byte) *GCSBuilder
- func WithKeyHash(keyHash *chainhash.Hash) *GCSBuilder
- func WithKeyHashP(keyHash *chainhash.Hash, p uint8) *GCSBuilder
- func WithKeyHashPN(keyHash *chainhash.Hash, p uint8, n uint32) *GCSBuilder
- func WithKeyP(key [gcs.KeySize]byte, p uint8) *GCSBuilder
- func WithKeyPN(key [gcs.KeySize]byte, p uint8, n uint32) *GCSBuilder
- func WithRandomKey() *GCSBuilder
- func WithRandomKeyP(p uint8) *GCSBuilder
- func WithRandomKeyPN(p uint8, n uint32) *GCSBuilder
- func (b *GCSBuilder) AddEntries(data [][]byte) *GCSBuilder
- func (b *GCSBuilder) AddEntry(data []byte) *GCSBuilder
- func (b *GCSBuilder) AddHash(hash *chainhash.Hash) *GCSBuilder
- func (b *GCSBuilder) AddOutPoint(outpoint wire.OutPoint) *GCSBuilder
- func (b *GCSBuilder) AddScript(script []byte) *GCSBuilder
- func (b *GCSBuilder) AddWitness(witness wire.TxWitness) *GCSBuilder
- func (b *GCSBuilder) Build() (*gcs.Filter, error)
- func (b *GCSBuilder) Key() ([gcs.KeySize]byte, error)
- func (b *GCSBuilder) Preallocate(n uint32) *GCSBuilder
- func (b *GCSBuilder) SetKey(key [gcs.KeySize]byte) *GCSBuilder
- func (b *GCSBuilder) SetKeyFromHash(keyHash *chainhash.Hash) *GCSBuilder
- func (b *GCSBuilder) SetP(p uint8) *GCSBuilder
Constants ¶
const DefaultP = 20
DefaultP is the default collision probability (2^-20)
Variables ¶
This section is empty.
Functions ¶
func BuildBasicFilter ¶
BuildBasicFilter builds a basic GCS filter from a block. A basic GCS filter will contain all the previous outpoints spent within a block, as well as the data pushes within all the outputs created within a block.
func BuildExtFilter ¶
BuildExtFilter builds an extended GCS filter from a block. An extended filter supplements a regular basic filter by include all the _witness_ data found within a block. This includes all the data pushes within any signature scripts as well as each element of an input's witness stack. Additionally, the _hashes_ of each transaction are also inserted into the filter.
func DeriveKey ¶
DeriveKey is a utility function that derives a key from a chainhash.Hash by truncating the bytes of the hash to the appopriate key size.
func GetFilterHash ¶
GetFilterHash returns the double-SHA256 of the filter.
func MakeHeaderForFilter ¶
MakeHeaderForFilter makes a filter chain header for a filter, given the filter and the previous filter chain header.
func OutPointToFilterEntry ¶
OutPointToFilterEntry is a utility function that derives a filter entry from a wire.OutPoint in a standardized way for use with both building and querying filters.
Types ¶
type GCSBuilder ¶
type GCSBuilder struct {
// contains filtered or unexported fields
}
GCSBuilder is a utility class that makes building GCS filters convenient.
func WithKey ¶
func WithKey(key [gcs.KeySize]byte) *GCSBuilder
WithKey creates a GCSBuilder with specified key. Probability is set to 20 (2^-20 collision probability). Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithKeyHash ¶
func WithKeyHash(keyHash *chainhash.Hash) *GCSBuilder
WithKeyHash creates a GCSBuilder with key derived from the specified chainhash.Hash. Probability is set to 20 (2^-20 collision probability). Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithKeyHashP ¶
func WithKeyHashP(keyHash *chainhash.Hash, p uint8) *GCSBuilder
WithKeyHashP creates a GCSBuilder with key derived from the specified chainhash.Hash and the passed probability. Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithKeyHashPN ¶
func WithKeyHashPN(keyHash *chainhash.Hash, p uint8, n uint32) *GCSBuilder
WithKeyHashPN creates a GCSBuilder with key derived from the specified chainhash.Hash and the passed probability and estimated filter size.
func WithKeyP ¶
func WithKeyP(key [gcs.KeySize]byte, p uint8) *GCSBuilder
WithKeyP creates a GCSBuilder with specified key and the passed probability. Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithKeyPN ¶
WithKeyPN creates a GCSBuilder with specified key and the passed probability and estimated filter size.
func WithRandomKey ¶
func WithRandomKey() *GCSBuilder
WithRandomKey creates a GCSBuilder with a cryptographically random key. Probability is set to 20 (2^-20 collision probability). Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithRandomKeyP ¶
func WithRandomKeyP(p uint8) *GCSBuilder
WithRandomKeyP creates a GCSBuilder with a cryptographically random key and the passed probability. Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithRandomKeyPN ¶
func WithRandomKeyPN(p uint8, n uint32) *GCSBuilder
WithRandomKeyPN creates a GCSBuilder with a cryptographically random key and the passed probability and estimated filter size.
func (*GCSBuilder) AddEntries ¶
func (b *GCSBuilder) AddEntries(data [][]byte) *GCSBuilder
AddEntries adds all the []byte entries in a [][]byte to the list of entries to be included in the GCS filter when it's built.
func (*GCSBuilder) AddEntry ¶
func (b *GCSBuilder) AddEntry(data []byte) *GCSBuilder
AddEntry adds a []byte to the list of entries to be included in the GCS filter when it's built.
func (*GCSBuilder) AddHash ¶
func (b *GCSBuilder) AddHash(hash *chainhash.Hash) *GCSBuilder
AddHash adds a chainhash.Hash to the list of entries to be included in the GCS filter when it's built.
func (*GCSBuilder) AddOutPoint ¶
func (b *GCSBuilder) AddOutPoint(outpoint wire.OutPoint) *GCSBuilder
AddOutPoint adds a wire.OutPoint to the list of entries to be included in the GCS filter when it's built.
func (*GCSBuilder) AddScript ¶
func (b *GCSBuilder) AddScript(script []byte) *GCSBuilder
AddScript adds all the data pushed in the script serialized as the passed []byte to the list of entries to be included in the GCS filter when it's built.
func (*GCSBuilder) AddWitness ¶
func (b *GCSBuilder) AddWitness(witness wire.TxWitness) *GCSBuilder
AddWitness adds each item of the passed filter stack to the filer.
func (*GCSBuilder) Build ¶
func (b *GCSBuilder) Build() (*gcs.Filter, error)
Build returns a function which builds a GCS filter with the given parameters and data.
func (*GCSBuilder) Key ¶
func (b *GCSBuilder) Key() ([gcs.KeySize]byte, error)
Key retrieves the key with which the builder will build a filter. This is useful if the builder is created with a random initial key.
func (*GCSBuilder) Preallocate ¶
func (b *GCSBuilder) Preallocate(n uint32) *GCSBuilder
Preallocate sets the estimated filter size after calling Builder() to reduce the probability of memory reallocations. If the builder has already had data added to it, Preallocate has no effect.
func (*GCSBuilder) SetKey ¶
func (b *GCSBuilder) SetKey(key [gcs.KeySize]byte) *GCSBuilder
SetKey sets the key with which the builder will build a filter to the passed [gcs.KeySize]byte.
func (*GCSBuilder) SetKeyFromHash ¶
func (b *GCSBuilder) SetKeyFromHash(keyHash *chainhash.Hash) *GCSBuilder
SetKeyFromHash sets the key with which the builder will build a filter to a key derived from the passed chainhash.Hash using DeriveKey().
func (*GCSBuilder) SetP ¶
func (b *GCSBuilder) SetP(p uint8) *GCSBuilder
SetP sets the filter's probability after calling Builder().