From 98e65a007d4ff94069bd6d06b207b88c97aa6159 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 14 Jun 2018 18:49:05 -0700 Subject: [PATCH] builder: remove outpoint methods --- gcs/builder/builder.go | 23 ----------------------- gcs/builder/builder_test.go | 18 ++---------------- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/gcs/builder/builder.go b/gcs/builder/builder.go index 02631d8..0343c7f 100644 --- a/gcs/builder/builder.go +++ b/gcs/builder/builder.go @@ -7,7 +7,6 @@ package builder import ( "crypto/rand" - "encoding/binary" "fmt" "math" @@ -67,17 +66,6 @@ func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte { return key } -// 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. -func OutPointToFilterEntry(outpoint wire.OutPoint) []byte { - // Size of the hash plus size of int32 index - data := make([]byte, chainhash.HashSize+4) - copy(data[:], outpoint.Hash.CloneBytes()[:]) - binary.LittleEndian.PutUint32(data[chainhash.HashSize:], outpoint.Index) - return data -} - // 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 (b *GCSBuilder) Key() ([gcs.KeySize]byte, error) { @@ -188,17 +176,6 @@ func (b *GCSBuilder) AddEntries(data [][]byte) *GCSBuilder { return b } -// AddOutPoint adds a wire.OutPoint to the list of entries to be included in -// the GCS filter when it's built. -func (b *GCSBuilder) AddOutPoint(outpoint wire.OutPoint) *GCSBuilder { - // Do nothing if the builder's already errored out. - if b.err != nil { - return b - } - - return b.AddEntry(OutPointToFilterEntry(outpoint)) -} - // AddHash adds a chainhash.Hash to the list of entries to be included in the // GCS filter when it's built. func (b *GCSBuilder) AddHash(hash *chainhash.Hash) *GCSBuilder { diff --git a/gcs/builder/builder_test.go b/gcs/builder/builder_test.go index ea75ff2..caf636f 100644 --- a/gcs/builder/builder_test.go +++ b/gcs/builder/builder_test.go @@ -178,8 +178,8 @@ func TestUseBlockHash(t *testing.T) { // Create a GCSBuilder with a known key and too-high P and ensure error // works throughout all functions that use it. b = builder.WithRandomKeyPM(33, 99).SetKeyFromHash(hash).SetKey(testKey) - b.SetP(30).AddEntry(hash.CloneBytes()).AddEntries(contents) - b.AddOutPoint(outPoint).AddHash(hash).AddScript(addrBytes) + b.SetP(30).AddEntry(hash.CloneBytes()).AddEntries(contents). + AddHash(hash).AddScript(addrBytes) _, err = b.Key() if err != gcs.ErrPTooBig { t.Fatalf("No error on P too big!") @@ -239,20 +239,6 @@ func BuilderTest(b *builder.GCSBuilder, hash *chainhash.Hash, p uint8, t.Fatal("Filter didn't match when it should have!") } - // Add a wire.OutPoint, build a filter, and test matches - b.AddOutPoint(outPoint) - f, err = b.Build() - if err != nil { - t.Fatalf("Filter build failed: %s", err.Error()) - } - match, err = f.Match(key, hash.CloneBytes()) - if err != nil { - t.Fatalf("Filter match failed: %s", err) - } - if !match { - t.Fatal("Filter didn't match when it should have!") - } - // Add a script, build a filter, and test matches b.AddEntry(addrBytes) f, err = b.Build()