Update ws example to use new filtered blocks ntfns.
The old notifications are now deprecated, so the examples shouldn't use them.
This commit is contained in:
parent
abcdfb702a
commit
eef39394b7
1 changed files with 8 additions and 6 deletions
|
@ -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
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcrpcclient"
|
"github.com/btcsuite/btcrpcclient"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -21,11 +21,13 @@ func main() {
|
||||||
// for notifications. See the documentation of the btcrpcclient
|
// for notifications. See the documentation of the btcrpcclient
|
||||||
// NotificationHandlers type for more details about each handler.
|
// NotificationHandlers type for more details about each handler.
|
||||||
ntfnHandlers := btcrpcclient.NotificationHandlers{
|
ntfnHandlers := btcrpcclient.NotificationHandlers{
|
||||||
OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time) {
|
OnFilteredBlockConnected: func(height int32, header *wire.BlockHeader, txns []*btcutil.Tx) {
|
||||||
log.Printf("Block connected: %v (%d) %v", hash, height, time)
|
log.Printf("Block connected: %v (%d) %v",
|
||||||
|
header.BlockHash(), height, header.Timestamp)
|
||||||
},
|
},
|
||||||
OnBlockDisconnected: func(hash *chainhash.Hash, height int32, time time.Time) {
|
OnFilteredBlockDisconnected: func(height int32, header *wire.BlockHeader) {
|
||||||
log.Printf("Block disconnected: %v (%d) %v", hash, height, time)
|
log.Printf("Block disconnected: %v (%d) %v",
|
||||||
|
header.BlockHash(), height, header.Timestamp)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue