Skip to content

Commit

Permalink
Populate filter #1 (extended)
Browse files Browse the repository at this point in the history
  • Loading branch information
martelletto authored and Roasbeef committed May 23, 2018
1 parent f16da15 commit f703e18
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion blockchain/indexers/cfindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ func (idx *CfIndex) Create(dbTx database.Tx) error {
}

// makeBasicFilter() builds a block's basic filter, which consists of all
// outpoints referenced by transactions within the block.
// outpoints and pkscript data pushes referenced by transactions within the
// block.
func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) {
b := builder.WithKeyHash(block.Hash())
_, err := b.Key()
Expand All @@ -129,6 +130,27 @@ func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) {
return f.Bytes(), nil
}

// makeExtendedFilter() builds a block's extended filter, which consists of
// all tx hashes and sigscript data pushes contained in the block.
func makeExtendedFilterForBlock(block *btcutil.Block) ([]byte, error) {
b := builder.WithKeyHash(block.Hash())
_, err := b.Key()
if err != nil {
return nil, err
}
for _, tx := range block.Transactions() {
b.AddHash(tx.Hash())
for _, txIn := range tx.MsgTx().TxIn {
b.AddScript(txIn.SignatureScript)
}
}
f, err := b.Build()
if err != nil {
return nil, err
}
return f.Bytes(), nil
}

// ConnectBlock is invoked by the index manager when a new block has been
// connected to the main chain. This indexer adds a hash-to-cf mapping for
// every passed block. This is part of the Indexer interface.
Expand Down

0 comments on commit f703e18

Please sign in to comment.