gcs/builder: remove the AddScript method as it's no longer used (#121)

In this commit, we remoec the AddScript method as it's no longer used,
and AddEntry should be used in place for adding pkScripts to the
filters.
This commit is contained in:
Olaoluwa Osuntokun 2018-07-06 18:06:48 -05:00 committed by GitHub
parent 7eb98d5700
commit ab6388e0c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 20 deletions

View file

@ -187,24 +187,6 @@ func (b *GCSBuilder) AddHash(hash *chainhash.Hash) *GCSBuilder {
return b.AddEntry(hash.CloneBytes()) return b.AddEntry(hash.CloneBytes())
} }
// 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 (b *GCSBuilder) AddScript(script []byte) *GCSBuilder {
// Do nothing if the builder's already errored out.
if b.err != nil {
return b
}
// Ignore errors and add pushed data, if any
data, _ := txscript.PushedData(script)
if len(data) == 0 {
return b
}
return b.AddEntries(data)
}
// AddWitness adds each item of the passed filter stack to the filter, and then // AddWitness adds each item of the passed filter stack to the filter, and then
// adds each item as a script. // adds each item as a script.
func (b *GCSBuilder) AddWitness(witness wire.TxWitness) *GCSBuilder { func (b *GCSBuilder) AddWitness(witness wire.TxWitness) *GCSBuilder {

View file

@ -179,7 +179,7 @@ func TestUseBlockHash(t *testing.T) {
// works throughout all functions that use it. // works throughout all functions that use it.
b = builder.WithRandomKeyPM(33, 99).SetKeyFromHash(hash).SetKey(testKey) b = builder.WithRandomKeyPM(33, 99).SetKeyFromHash(hash).SetKey(testKey)
b.SetP(30).AddEntry(hash.CloneBytes()).AddEntries(contents). b.SetP(30).AddEntry(hash.CloneBytes()).AddEntries(contents).
AddHash(hash).AddScript(addrBytes) AddHash(hash).AddEntry(addrBytes)
_, err = b.Key() _, err = b.Key()
if err != gcs.ErrPTooBig { if err != gcs.ErrPTooBig {
t.Fatalf("No error on P too big!") t.Fatalf("No error on P too big!")
@ -270,7 +270,7 @@ func BuilderTest(b *builder.GCSBuilder, hash *chainhash.Hash, p uint8,
// Check that adding duplicate items does not increase filter size. // Check that adding duplicate items does not increase filter size.
originalSize := f.N() originalSize := f.N()
b.AddScript(addrBytes) b.AddEntry(addrBytes)
b.AddWitness(witness) b.AddWitness(witness)
f, err = b.Build() f, err = b.Build()
if err != nil { if err != nil {