Update for notifyallnewtxs rename.

The websocket extension command to register for notifications when a new
transaction has been accepted to the memory pool and the resulting
notifications have been renamed.  This commit catches up to the change.
This commit is contained in:
Dave Collins 2014-04-15 00:29:49 -05:00
parent 05a7979292
commit a4673597bd

View file

@ -46,13 +46,13 @@ type wsCommandHandler func(*wsClient, btcjson.Cmd) (interface{}, *btcjson.Error)
// wsHandlers maps RPC command strings to appropriate websocket handler // wsHandlers maps RPC command strings to appropriate websocket handler
// functions. // functions.
var wsHandlers = map[string]wsCommandHandler{ var wsHandlers = map[string]wsCommandHandler{
"getbestblock": handleGetBestBlock, "getbestblock": handleGetBestBlock,
"getcurrentnet": handleGetCurrentNet, "getcurrentnet": handleGetCurrentNet,
"notifyblocks": handleNotifyBlocks, "notifyblocks": handleNotifyBlocks,
"notifyallnewtxs": handleNotifyAllNewTXs, "notifynewtransactions": handleNotifyNewTransactions,
"notifyreceived": handleNotifyReceived, "notifyreceived": handleNotifyReceived,
"notifyspent": handleNotifySpent, "notifyspent": handleNotifySpent,
"rescan": handleRescan, "rescan": handleRescan,
} }
// wsAsyncHandlers holds the websocket commands which should be run // wsAsyncHandlers holds the websocket commands which should be run
@ -475,14 +475,14 @@ func (m *wsNotificationManager) notifyForNewTx(clients map[chan bool]*wsClient,
amount += txOut.Value amount += txOut.Value
} }
ntfn := btcws.NewAllTxNtfn(txShaStr, amount) ntfn := btcws.NewTxAcceptedNtfn(txShaStr, amount)
marshalledJSON, err := json.Marshal(ntfn) marshalledJSON, err := json.Marshal(ntfn)
if err != nil { if err != nil {
rpcsLog.Errorf("Failed to marshal tx notification: %s", err.Error()) rpcsLog.Errorf("Failed to marshal tx notification: %s", err.Error())
return return
} }
var verboseNtfn *btcws.AllVerboseTxNtfn var verboseNtfn *btcws.TxAcceptedVerboseNtfn
var marshalledJSONVerbose []byte var marshalledJSONVerbose []byte
for _, wsc := range clients { for _, wsc := range clients {
if wsc.verboseTxUpdates { if wsc.verboseTxUpdates {
@ -493,7 +493,7 @@ func (m *wsNotificationManager) notifyForNewTx(clients map[chan bool]*wsClient,
if err != nil { if err != nil {
return return
} }
verboseNtfn = btcws.NewAllVerboseTxNtfn(rawTx) verboseNtfn = btcws.NewTxAcceptedVerboseNtfn(rawTx)
marshalledJSONVerbose, err = json.Marshal(verboseNtfn) marshalledJSONVerbose, err = json.Marshal(verboseNtfn)
if err != nil { if err != nil {
rpcsLog.Errorf("Failed to marshal verbose tx notification: %s", err.Error()) rpcsLog.Errorf("Failed to marshal verbose tx notification: %s", err.Error())
@ -1430,10 +1430,10 @@ func handleNotifySpent(wsc *wsClient, icmd btcjson.Cmd) (interface{}, *btcjson.E
return nil, nil return nil, nil
} }
// handleNotifyAllNewTXs implements the notifyallnewtxs command extension for // handleNotifyNewTransations implements the notifynewtransactions command
// websocket connections. // extension for websocket connections.
func handleNotifyAllNewTXs(wsc *wsClient, icmd btcjson.Cmd) (interface{}, *btcjson.Error) { func handleNotifyNewTransactions(wsc *wsClient, icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
cmd, ok := icmd.(*btcws.NotifyAllNewTXsCmd) cmd, ok := icmd.(*btcws.NotifyNewTransactionsCmd)
if !ok { if !ok {
return nil, &btcjson.ErrInternal return nil, &btcjson.ErrInternal
} }