From eef39394b7eb639be140973f8f2dcc2020784f5f Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 25 Jan 2017 23:48:44 -0600 Subject: [PATCH] Update ws example to use new filtered blocks ntfns. The old notifications are now deprecated, so the examples shouldn't use them. --- examples/btcdwebsockets/main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/btcdwebsockets/main.go b/examples/btcdwebsockets/main.go index 93809953..96c50a19 100644 --- a/examples/btcdwebsockets/main.go +++ b/examples/btcdwebsockets/main.go @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2015 The btcsuite developers +// Copyright (c) 2014-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -10,7 +10,7 @@ import ( "path/filepath" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcrpcclient" "github.com/btcsuite/btcutil" ) @@ -21,11 +21,13 @@ func main() { // for notifications. See the documentation of the btcrpcclient // NotificationHandlers type for more details about each handler. ntfnHandlers := btcrpcclient.NotificationHandlers{ - OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time) { - log.Printf("Block connected: %v (%d) %v", hash, height, time) + OnFilteredBlockConnected: func(height int32, header *wire.BlockHeader, txns []*btcutil.Tx) { + log.Printf("Block connected: %v (%d) %v", + header.BlockHash(), height, header.Timestamp) }, - OnBlockDisconnected: func(hash *chainhash.Hash, height int32, time time.Time) { - log.Printf("Block disconnected: %v (%d) %v", hash, height, time) + OnFilteredBlockDisconnected: func(height int32, header *wire.BlockHeader) { + log.Printf("Block disconnected: %v (%d) %v", + header.BlockHash(), height, header.Timestamp) }, }