Documentation ¶
Index ¶
- Constants
- Variables
- func BuildBasicFilter(block *wire.Block, prevOutScripts [][]byte) (*gcs.Filter, error)
- func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte
- func GetFilterHash(filter *gcs.Filter) (chainhash.Hash, error)
- func MakeHeaderForFilter(filter *gcs.Filter, prevHeader chainhash.Hash) (chainhash.Hash, error)
- func RandomKey() (key [gcs.KeySize]byte, e error)
- type GCS
- func WithKey(key [gcs.KeySize]byte) *GCS
- func WithKeyHash(keyHash *chainhash.Hash) *GCS
- func WithKeyHashPM(keyHash *chainhash.Hash, p uint8, m uint64) *GCS
- func WithKeyHashPNM(keyHash *chainhash.Hash, p uint8, n uint32, m uint64) *GCS
- func WithKeyPM(key [gcs.KeySize]byte, p uint8, m uint64) *GCS
- func WithKeyPNM(key [gcs.KeySize]byte, p uint8, n uint32, m uint64) *GCS
- func WithRandomKey() *GCS
- func WithRandomKeyPM(p uint8, m uint64) *GCS
- func WithRandomKeyPNM(p uint8, n uint32, m uint64) *GCS
- func (b *GCS) AddEntries(data [][]byte) *GCS
- func (b *GCS) AddEntry(data []byte) *GCS
- func (b *GCS) AddHash(hash *chainhash.Hash) *GCS
- func (b *GCS) AddWitness(witness wire.TxWitness) *GCS
- func (b *GCS) Build() (*gcs.Filter, error)
- func (b *GCS) Key() ([gcs.KeySize]byte, error)
- func (b *GCS) Preallocate(n uint32) *GCS
- func (b *GCS) SetKey(key [gcs.KeySize]byte) *GCS
- func (b *GCS) SetKeyFromHash(keyHash *chainhash.Hash) *GCS
- func (b *GCS) SetM(m uint64) *GCS
- func (b *GCS) SetP(p uint8) *GCS
Constants ¶
const ( // DefaultP is the default collision probability (2^-19) DefaultP = 19 // DefaultM is the default value used for the hash range. DefaultM uint64 = 784931 )
Variables ¶
var F, E, W, I, D, T log.LevelPrinter = log.GetLogPrinterSet(subsystem)
Functions ¶
func BuildBasicFilter ¶
BuildBasicFilter builds a basic GCS filter from a block. A basic GCS filter will contain all the previous output scripts spent by inputs within a block, as well as the data pushes within all the outputs created within a block.
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.
Types ¶
type GCS ¶
type GCS struct {
// contains filtered or unexported fields
}
GCS is a utility class that makes building GCS filters convenient.
func WithKey ¶
WithKey creates a GCS with specified key. Probability is set to 19 (2^-19 collision probability). Estimated filter size is set to zero, which means more reallocations are done when building the filter.
func WithKeyHash ¶
WithKeyHash creates a GCS 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 WithKeyHashPM ¶
WithKeyHashPM creates a GCS 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 WithKeyHashPNM ¶
WithKeyHashPNM creates a GCS with key derived from the specified chainhash.Hash and the passed probability and estimated filter size.
func WithKeyPM ¶
WithKeyPM creates a GCS 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 WithKeyPNM ¶
WithKeyPNM creates a GCS with specified key and the passed probability, modulus and estimated filter size.
func WithRandomKey ¶
func WithRandomKey() *GCS
WithRandomKey creates a GCS 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 WithRandomKeyPM ¶
WithRandomKeyPM creates a GCS 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 WithRandomKeyPNM ¶
WithRandomKeyPNM creates a GCS with a cryptographically random key and the passed probability and estimated filter size.
func (*GCS) AddEntries ¶
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 (*GCS) AddEntry ¶
AddEntry adds a []byte to the list of entries to be included in the GCS filter when it's built.
func (*GCS) AddHash ¶
AddHash adds a chainhash.Hash to the list of entries to be included in the GCS filter when it's built.
func (*GCS) AddWitness ¶
AddWitness adds each item of the passed filter stack to the filter, and then adds each item as a script.
func (*GCS) Build ¶
Build returns a function which builds a GCS filter with the given parameters and data.
func (*GCS) Key ¶
Key retrieves the key with which the builder will podbuild a filter. This is useful if the builder is created with a random initial key.
func (*GCS) Preallocate ¶
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 (*GCS) SetKey ¶
SetKey sets the key with which the builder will podbuild a filter to the passed [gcs.KeySize]byte.
func (*GCS) SetKeyFromHash ¶
SetKeyFromHash sets the key with which the builder will podbuild a filter to a key derived from the passed chainhash.Hash using DeriveKey().