Populate filter #1 (extended)
This commit is contained in:
parent
f16da156c9
commit
f703e18652
1 changed files with 23 additions and 1 deletions
|
@ -107,7 +107,8 @@ func (idx *CfIndex) Create(dbTx database.Tx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeBasicFilter() builds a block's basic filter, which consists of all
|
// 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) {
|
func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) {
|
||||||
b := builder.WithKeyHash(block.Hash())
|
b := builder.WithKeyHash(block.Hash())
|
||||||
_, err := b.Key()
|
_, err := b.Key()
|
||||||
|
@ -129,6 +130,27 @@ func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) {
|
||||||
return f.Bytes(), nil
|
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
|
// 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
|
// connected to the main chain. This indexer adds a hash-to-cf mapping for
|
||||||
// every passed block. This is part of the Indexer interface.
|
// every passed block. This is part of the Indexer interface.
|
||||||
|
|
Loading…
Reference in a new issue