Populate filter #1 (extended)

This commit is contained in:
pedro martelletto 2017-01-20 13:21:49 +00:00 committed by Olaoluwa Osuntokun
parent f16da156c9
commit f703e18652

View file

@ -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()
@ -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.