Look up filters from p2p GetCBF message
This commit is contained in:
parent
76926f8904
commit
43bf8db793
2 changed files with 19 additions and 2 deletions
|
@ -156,6 +156,17 @@ func (idx *CBFIndex) DisconnectBlock(dbTx database.Tx, block *btcutil.Block, vie
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (idx *CBFIndex) GetFilterByBlockHash(hash *chainhash.Hash) ([]byte,
|
||||||
|
error) {
|
||||||
|
var filterBytes []byte
|
||||||
|
err := idx.db.View(func(dbTx database.Tx) error {
|
||||||
|
var err error
|
||||||
|
filterBytes, err = dbFetchCBFIndexEntry(dbTx, hash)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
return filterBytes, err
|
||||||
|
}
|
||||||
|
|
||||||
// NewCBFIndex returns a new instance of an indexer that is used to create a
|
// NewCBFIndex returns a new instance of an indexer that is used to create a
|
||||||
// mapping of the hashes of all blocks in the blockchain to their respective
|
// mapping of the hashes of all blocks in the blockchain to their respective
|
||||||
// committed bloom filters.
|
// committed bloom filters.
|
||||||
|
|
10
server.go
10
server.go
|
@ -746,8 +746,14 @@ func (sp *serverPeer) OnGetCBFilter(_ *peer.Peer, msg *wire.MsgGetCBFilter) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX work in progress
|
filterBytes, err := sp.server.cbfIndex.GetFilterByBlockHash(&msg.BlockHash)
|
||||||
peerLog.Warnf("received OnGetCBFilter: not yet")
|
|
||||||
|
if len(filterBytes) > 0 {
|
||||||
|
peerLog.Infof("Obtained CB filter for %v", msg.BlockHash)
|
||||||
|
} else {
|
||||||
|
peerLog.Infof("Could not obtain CB filter for %v: %v",
|
||||||
|
msg.BlockHash, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforceNodeBloomFlag disconnects the peer if the server is not configured to
|
// enforceNodeBloomFlag disconnects the peer if the server is not configured to
|
||||||
|
|
Loading…
Reference in a new issue