server: add OnGetCFTypes callback to serverPeer

This commit is contained in:
Alex 2017-10-10 21:28:21 -06:00 committed by Olaoluwa Osuntokun
parent 2b7ebfd698
commit 5772bdde86

View file

@ -873,6 +873,18 @@ func (sp *serverPeer) OnGetCFHeaders(_ *peer.Peer, msg *wire.MsgGetCFHeaders) {
sp.QueueMessage(headersMsg, nil) sp.QueueMessage(headersMsg, nil)
} }
// OnGetCFTypes is invoked when a peer receives a getcftypes bitcoin message.
func (sp *serverPeer) OnGetCFTypes(_ *peer.Peer, msg *wire.MsgGetCFTypes) {
// Ignore getcftypes requests if cfg.NoCFilters is set or we're not in
// sync.
if cfg.NoCFilters || !sp.server.blockManager.IsCurrent() {
return
}
cfTypesMsg := wire.NewMsgCFTypes([]uint8{0, 1})
sp.QueueMessage(cfTypesMsg, nil)
}
// enforceNodeBloomFlag disconnects the peer if the server is not configured to // enforceNodeBloomFlag disconnects the peer if the server is not configured to
// allow bloom filters. Additionally, if the peer has negotiated to a protocol // allow bloom filters. Additionally, if the peer has negotiated to a protocol
// version that is high enough to observe the bloom filter service support bit, // version that is high enough to observe the bloom filter service support bit,
@ -1722,6 +1734,7 @@ func newPeerConfig(sp *serverPeer) *peer.Config {
OnGetHeaders: sp.OnGetHeaders, OnGetHeaders: sp.OnGetHeaders,
OnGetCFilter: sp.OnGetCFilter, OnGetCFilter: sp.OnGetCFilter,
OnGetCFHeaders: sp.OnGetCFHeaders, OnGetCFHeaders: sp.OnGetCFHeaders,
OnGetCFTypes: sp.OnGetCFTypes,
OnFeeFilter: sp.OnFeeFilter, OnFeeFilter: sp.OnFeeFilter,
OnFilterAdd: sp.OnFilterAdd, OnFilterAdd: sp.OnFilterAdd,
OnFilterClear: sp.OnFilterClear, OnFilterClear: sp.OnFilterClear,