code: func (m *wsNotificationManager) notifyFilteredBlockConnected(clients map[chan struct{}]*wsClient,
  	block *btcutil.Block) {
  
  	// Create the common portion of the notification that is the same for
  	// every client.
  	var w bytes.Buffer
  	err := block.MsgBlock().Header.Serialize(&w)
  	if err != nil {
  		rpcsLog.Errorf("Failed to serialize header for filtered block "+
  			"connected notification: %v", err)
  		return
  	}
  	ntfn := btcjson.NewFilteredBlockConnectedNtfn(block.Height(),
  		hex.EncodeToString(w.Bytes()), nil)
  
  	// Search for relevant transactions for each client and save them
  	// serialized in hex encoding for the notification.
  	subscribedTxs := make(map[chan struct{}][]string)
  	for _, tx := range block.Transactions() {
  		var txHex string
  		for quitChan := range m.subscribedClients(tx, clients) {
  			if txHex == "" {
  				txHex = txHexString(tx.MsgTx())
  			}
  			subscribedTxs[quitChan] = append(subscribedTxs[quitChan], txHex)
  		}
  	}
  	for quitChan, wsc := range clients {
  		// Add all discovered transactions for this client. For clients
  		// that have no new-style filter, add the empty string slice.
  		ntfn.SubscribedTxs = subscribedTxs[quitChan]
  
  		// Marshal and queue notification.
  		marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
  		if err != nil {
  			rpcsLog.Errorf("Failed to marshal filtered block "+
  				"connected notification: %v", err)
  			return
  		}
  		wsc.QueueNotification(marshalledJSON)
  	}
  }
docs: // notifyFilteredBlockConnected notifies websocket clients that have registered for
  // block updates when a block is connected to the main chain.