gcs/builder: update regular filter to exclude txid
In this commit, we update the regular filter to exclude the txid, as in most cases we can use the output script for the same purpose.
This commit is contained in:
parent
5d1446c6ce
commit
3b3422dc54
2 changed files with 8 additions and 11 deletions
|
@ -20,7 +20,8 @@ const DefaultP = 20
|
||||||
|
|
||||||
// GCSBuilder is a utility class that makes building GCS filters convenient.
|
// GCSBuilder is a utility class that makes building GCS filters convenient.
|
||||||
type GCSBuilder struct {
|
type GCSBuilder struct {
|
||||||
p uint8
|
p uint8
|
||||||
|
|
||||||
key [gcs.KeySize]byte
|
key [gcs.KeySize]byte
|
||||||
|
|
||||||
// data is a set of entries represented as strings. This is done to
|
// data is a set of entries represented as strings. This is done to
|
||||||
|
@ -242,8 +243,8 @@ func WithKeyP(key [gcs.KeySize]byte, p uint8) *GCSBuilder {
|
||||||
return WithKeyPN(key, p, 0)
|
return WithKeyPN(key, p, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithKey creates a GCSBuilder with specified key. Probability is set to
|
// WithKey creates a GCSBuilder with specified key. Probability is set to 19
|
||||||
// 20 (2^-20 collision probability). Estimated filter size is set to zero, which
|
// (2^-19 collision probability). Estimated filter size is set to zero, which
|
||||||
// means more reallocations are done when building the filter.
|
// means more reallocations are done when building the filter.
|
||||||
func WithKey(key [gcs.KeySize]byte) *GCSBuilder {
|
func WithKey(key [gcs.KeySize]byte) *GCSBuilder {
|
||||||
return WithKeyPN(key, DefaultP, 0)
|
return WithKeyPN(key, DefaultP, 0)
|
||||||
|
@ -314,11 +315,6 @@ func BuildBasicFilter(block *wire.MsgBlock) (*gcs.Filter, error) {
|
||||||
// adding the outpoint data as well as the data pushes within the
|
// adding the outpoint data as well as the data pushes within the
|
||||||
// pkScript.
|
// pkScript.
|
||||||
for i, tx := range block.Transactions {
|
for i, tx := range block.Transactions {
|
||||||
// First we'll compute the bash of the transaction and add that
|
|
||||||
// directly to the filter.
|
|
||||||
txHash := tx.TxHash()
|
|
||||||
b.AddHash(&txHash)
|
|
||||||
|
|
||||||
// Skip the inputs for the coinbase transaction
|
// Skip the inputs for the coinbase transaction
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
// Each each txin, we'll add a serialized version of
|
// Each each txin, we'll add a serialized version of
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/roasbeef/btcutil/gcs"
|
"github.com/btcsuite/btcutil/gcs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func genRandFilterElements(numElements uint) ([][]byte, error) {
|
func genRandFilterElements(numElements uint) ([][]byte, error) {
|
||||||
|
@ -46,8 +46,9 @@ func BenchmarkGCSFilterBuild50000(b *testing.B) {
|
||||||
|
|
||||||
var localFilter *gcs.Filter
|
var localFilter *gcs.Filter
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
localFilter, err = gcs.BuildGCSFilter(P, key,
|
localFilter, err = gcs.BuildGCSFilter(
|
||||||
randFilterElems)
|
P, key, randFilterElems,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("unable to generate filter: %v", err)
|
b.Fatalf("unable to generate filter: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue