Explicitly request block notifications.
This commit is contained in:
parent
a309196ea2
commit
f87aab49df
2 changed files with 11 additions and 0 deletions
8
rpc.go
8
rpc.go
|
@ -113,6 +113,14 @@ func GetCurrentNet(rpc RPCConn) (btcwire.BitcoinNet, *btcjson.Error) {
|
|||
return btcwire.BitcoinNet(uint32(response.Result.(float64))), nil
|
||||
}
|
||||
|
||||
// NotifyBlocks requests blockconnected and blockdisconnected notifications.
|
||||
func NotifyBlocks(rpc RPCConn) *btcjson.Error {
|
||||
cmd := btcws.NewNotifyBlocksCmd(<-NewJSONID)
|
||||
request := NewRPCRequest(cmd, nil)
|
||||
response := <-rpc.SendRequest(request)
|
||||
return response.Err
|
||||
}
|
||||
|
||||
// NotifyNewTXs requests notifications for new transactions that spend
|
||||
// to any of the addresses in addrs.
|
||||
func NotifyNewTXs(rpc RPCConn, addrs []string) *btcjson.Error {
|
||||
|
|
|
@ -507,6 +507,9 @@ func Handshake(rpc RPCConn) error {
|
|||
return errors.New("btcd and btcwallet running on different Bitcoin networks")
|
||||
}
|
||||
|
||||
// Request notifications for connected and disconnected blocks.
|
||||
NotifyBlocks(rpc)
|
||||
|
||||
// Get current best block. If this is before than the oldest
|
||||
// saved block hash, assume that this btcd instance is not yet
|
||||
// synced up to a previous btcd that was last used with this
|
||||
|
|
Loading…
Reference in a new issue