Rename RescanResultNtfn to ProcessedTxNtfn.
This notification should be generic enough to be used by both rescan and normal block processing code, so give it a generic name too.
This commit is contained in:
parent
9ea77c00f2
commit
6e3f9e451b
3 changed files with 29 additions and 29 deletions
|
@ -34,9 +34,9 @@ const (
|
||||||
// btcdconnected notification.
|
// btcdconnected notification.
|
||||||
BtcdConnectedNtfnMethod = "btcdconnected"
|
BtcdConnectedNtfnMethod = "btcdconnected"
|
||||||
|
|
||||||
// RescanResultNtfnMethod is the method of the btcd
|
// ProcessedTxNtfnMethod is the method of the btcd
|
||||||
// rescanresult notification.
|
// processedtx notification.
|
||||||
RescanResultNtfnMethod = "rescanresult"
|
ProcessedTxNtfnMethod = "processedx"
|
||||||
|
|
||||||
// TxMinedNtfnMethod is the method of the btcd txmined
|
// TxMinedNtfnMethod is the method of the btcd txmined
|
||||||
// notification.
|
// notification.
|
||||||
|
@ -57,7 +57,7 @@ func init() {
|
||||||
btcjson.RegisterCustomCmd(BlockConnectedNtfnMethod, parseBlockConnectedNtfn)
|
btcjson.RegisterCustomCmd(BlockConnectedNtfnMethod, parseBlockConnectedNtfn)
|
||||||
btcjson.RegisterCustomCmd(BlockDisconnectedNtfnMethod, parseBlockDisconnectedNtfn)
|
btcjson.RegisterCustomCmd(BlockDisconnectedNtfnMethod, parseBlockDisconnectedNtfn)
|
||||||
btcjson.RegisterCustomCmd(BtcdConnectedNtfnMethod, parseBtcdConnectedNtfn)
|
btcjson.RegisterCustomCmd(BtcdConnectedNtfnMethod, parseBtcdConnectedNtfn)
|
||||||
btcjson.RegisterCustomCmd(RescanResultNtfnMethod, parseRescanResultNtfn)
|
btcjson.RegisterCustomCmd(ProcessedTxNtfnMethod, parseProcessedTxNtfn)
|
||||||
btcjson.RegisterCustomCmd(TxMinedNtfnMethod, parseTxMinedNtfn)
|
btcjson.RegisterCustomCmd(TxMinedNtfnMethod, parseTxMinedNtfn)
|
||||||
btcjson.RegisterCustomCmd(TxNtfnMethod, parseTxNtfn)
|
btcjson.RegisterCustomCmd(TxNtfnMethod, parseTxNtfn)
|
||||||
btcjson.RegisterCustomCmd(WalletLockStateNtfnMethod, parseWalletLockStateNtfn)
|
btcjson.RegisterCustomCmd(WalletLockStateNtfnMethod, parseWalletLockStateNtfn)
|
||||||
|
@ -440,9 +440,9 @@ func (n *BtcdConnectedNtfn) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RescanResultNtfn is a type handling custom marshaling and unmarshaling
|
// ProcessedTxNtfn is a type handling custom marshaling and unmarshaling
|
||||||
// of rescanresult JSON websocket notifications.
|
// of processedtx JSON websocket notifications.
|
||||||
type RescanResultNtfn struct {
|
type ProcessedTxNtfn struct {
|
||||||
Receiver string
|
Receiver string
|
||||||
Amount int64
|
Amount int64
|
||||||
TxID string
|
TxID string
|
||||||
|
@ -455,13 +455,13 @@ type RescanResultNtfn struct {
|
||||||
Spent bool
|
Spent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce that RescanResultNtfn satisifies the btcjson.Cmd interface.
|
// Enforce that ProcessedTxNtfn satisifies the btcjson.Cmd interface.
|
||||||
var _ btcjson.Cmd = &RescanResultNtfn{}
|
var _ btcjson.Cmd = &ProcessedTxNtfn{}
|
||||||
|
|
||||||
// parseRescanResultNtfn parses a RawCmd into a concrete type satisifying
|
// parseProcessedTxNtfn parses a RawCmd into a concrete type satisifying
|
||||||
// the btcjson.Cmd interface. This is used when registering the notification
|
// the btcjson.Cmd interface. This is used when registering the notification
|
||||||
// with the btcjson parser.
|
// with the btcjson parser.
|
||||||
func parseRescanResultNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
func parseProcessedTxNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
if r.Id != nil {
|
if r.Id != nil {
|
||||||
return nil, ErrNotANtfn
|
return nil, ErrNotANtfn
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ func parseRescanResultNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
return nil, errors.New("tenth parameter spent must be a bool")
|
return nil, errors.New("tenth parameter spent must be a bool")
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := &RescanResultNtfn{
|
cmd := &ProcessedTxNtfn{
|
||||||
Receiver: receiver,
|
Receiver: receiver,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
TxID: txid,
|
TxID: txid,
|
||||||
|
@ -533,23 +533,23 @@ func parseRescanResultNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
|
|
||||||
// Id satisifies the btcjson.Cmd interface by returning nil for a
|
// Id satisifies the btcjson.Cmd interface by returning nil for a
|
||||||
// notification ID.
|
// notification ID.
|
||||||
func (n *RescanResultNtfn) Id() interface{} {
|
func (n *ProcessedTxNtfn) Id() interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetId is implemented to satisify the btcjson.Cmd interface. The
|
// SetId is implemented to satisify the btcjson.Cmd interface. The
|
||||||
// notification id is not modified.
|
// notification id is not modified.
|
||||||
func (n *RescanResultNtfn) SetId(id interface{}) {}
|
func (n *ProcessedTxNtfn) SetId(id interface{}) {}
|
||||||
|
|
||||||
// Method satisifies the btcjson.Cmd interface by returning the method
|
// Method satisifies the btcjson.Cmd interface by returning the method
|
||||||
// of the notification.
|
// of the notification.
|
||||||
func (n *RescanResultNtfn) Method() string {
|
func (n *ProcessedTxNtfn) Method() string {
|
||||||
return RescanResultNtfnMethod
|
return ProcessedTxNtfnMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON returns the JSON encoding of n. Part of the btcjson.Cmd
|
// MarshalJSON returns the JSON encoding of n. Part of the btcjson.Cmd
|
||||||
// interface.
|
// interface.
|
||||||
func (n *RescanResultNtfn) MarshalJSON() ([]byte, error) {
|
func (n *ProcessedTxNtfn) MarshalJSON() ([]byte, error) {
|
||||||
ntfn := btcjson.Message{
|
ntfn := btcjson.Message{
|
||||||
Jsonrpc: "1.0",
|
Jsonrpc: "1.0",
|
||||||
Method: n.Method(),
|
Method: n.Method(),
|
||||||
|
@ -571,19 +571,19 @@ func (n *RescanResultNtfn) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals the JSON encoding of n into n. Part of
|
// UnmarshalJSON unmarshals the JSON encoding of n into n. Part of
|
||||||
// the btcjson.Cmd interface.
|
// the btcjson.Cmd interface.
|
||||||
func (n *RescanResultNtfn) UnmarshalJSON(b []byte) error {
|
func (n *ProcessedTxNtfn) UnmarshalJSON(b []byte) error {
|
||||||
// Unmarshal into a RawCmd.
|
// Unmarshal into a RawCmd.
|
||||||
var r btcjson.RawCmd
|
var r btcjson.RawCmd
|
||||||
if err := json.Unmarshal(b, &r); err != nil {
|
if err := json.Unmarshal(b, &r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
newNtfn, err := parseRescanResultNtfn(&r)
|
newNtfn, err := parseProcessedTxNtfn(&r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
concreteNtfn, ok := newNtfn.(*RescanResultNtfn)
|
concreteNtfn, ok := newNtfn.(*ProcessedTxNtfn)
|
||||||
if !ok {
|
if !ok {
|
||||||
return btcjson.ErrInternal
|
return btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,9 @@ var ntfntests = []struct {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "rescanresult",
|
name: "processedtx",
|
||||||
f: func() btcjson.Cmd {
|
f: func() btcjson.Cmd {
|
||||||
cmd := &btcws.RescanResultNtfn{
|
cmd := &btcws.ProcessedTxNtfn{
|
||||||
Receiver: "miFxiuApPo3KBqtMnPUjasZmHoVnoH3Eoc",
|
Receiver: "miFxiuApPo3KBqtMnPUjasZmHoVnoH3Eoc",
|
||||||
Amount: 200000000,
|
Amount: 200000000,
|
||||||
TxID: "851f5c0652e785c5ed80aafaf2d918e5cbe5c307dbba3680808ada1d01f36886",
|
TxID: "851f5c0652e785c5ed80aafaf2d918e5cbe5c307dbba3680808ada1d01f36886",
|
||||||
|
@ -78,7 +78,7 @@ var ntfntests = []struct {
|
||||||
}
|
}
|
||||||
return cmd
|
return cmd
|
||||||
},
|
},
|
||||||
result: &btcws.RescanResultNtfn{
|
result: &btcws.ProcessedTxNtfn{
|
||||||
Receiver: "miFxiuApPo3KBqtMnPUjasZmHoVnoH3Eoc",
|
Receiver: "miFxiuApPo3KBqtMnPUjasZmHoVnoH3Eoc",
|
||||||
Amount: 200000000,
|
Amount: 200000000,
|
||||||
TxID: "851f5c0652e785c5ed80aafaf2d918e5cbe5c307dbba3680808ada1d01f36886",
|
TxID: "851f5c0652e785c5ed80aafaf2d918e5cbe5c307dbba3680808ada1d01f36886",
|
||||||
|
|
|
@ -10,7 +10,7 @@ github.com/conformal/btcws/cmds.go GetAddressBalanceCmd.MarshalJSON 100.00%
|
||||||
github.com/conformal/btcws/cmds.go GetBalancesCmd.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/cmds.go GetBalancesCmd.MarshalJSON 100.00% (2/2)
|
||||||
github.com/conformal/btcws/cmds.go NotifyNewTXsCmd.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/cmds.go NotifyNewTXsCmd.MarshalJSON 100.00% (2/2)
|
||||||
github.com/conformal/btcws/notifications.go TxMinedNtfn.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/notifications.go TxMinedNtfn.MarshalJSON 100.00% (2/2)
|
||||||
github.com/conformal/btcws/notifications.go RescanResultNtfn.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/notifications.go ProcessedTxNtfn.MarshalJSON 100.00% (2/2)
|
||||||
github.com/conformal/btcws/notifications.go TxNtfn.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/notifications.go TxNtfn.MarshalJSON 100.00% (2/2)
|
||||||
github.com/conformal/btcws/cmds.go NotifySpentCmd.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/cmds.go NotifySpentCmd.MarshalJSON 100.00% (2/2)
|
||||||
github.com/conformal/btcws/cmds.go GetCurrentNetCmd.MarshalJSON 100.00% (2/2)
|
github.com/conformal/btcws/cmds.go GetCurrentNetCmd.MarshalJSON 100.00% (2/2)
|
||||||
|
@ -64,10 +64,10 @@ github.com/conformal/btcws/cmds.go NewNotifyNewTXsCmd 100.00% (1/1)
|
||||||
github.com/conformal/btcws/cmds.go NotifyNewTXsCmd.Id 100.00% (1/1)
|
github.com/conformal/btcws/cmds.go NotifyNewTXsCmd.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcws/notifications.go TxNtfn.Id 100.00% (1/1)
|
github.com/conformal/btcws/notifications.go TxNtfn.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcws/cmds.go ListAddressTransactionsCmd.Id 100.00% (1/1)
|
github.com/conformal/btcws/cmds.go ListAddressTransactionsCmd.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcws/notifications.go RescanResultNtfn.Method 100.00% (1/1)
|
github.com/conformal/btcws/notifications.go ProcessedTxNtfn.Method 100.00% (1/1)
|
||||||
github.com/conformal/btcws/cmds.go ListAddressTransactionsCmd.Method 100.00% (1/1)
|
github.com/conformal/btcws/cmds.go ListAddressTransactionsCmd.Method 100.00% (1/1)
|
||||||
github.com/conformal/btcws/cmds.go ListAllTransactionsCmd.Id 100.00% (1/1)
|
github.com/conformal/btcws/cmds.go ListAllTransactionsCmd.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcws/notifications.go RescanResultNtfn.Id 100.00% (1/1)
|
github.com/conformal/btcws/notifications.go ProcessedTxNtfn.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcws/cmds.go ListAllTransactionsCmd.Method 100.00% (1/1)
|
github.com/conformal/btcws/cmds.go ListAllTransactionsCmd.Method 100.00% (1/1)
|
||||||
github.com/conformal/btcws/notifications.go WalletLockStateNtfn.Id 100.00% (1/1)
|
github.com/conformal/btcws/notifications.go WalletLockStateNtfn.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcws/cmds.go GetUnconfirmedBalanceCmd.Method 100.00% (1/1)
|
github.com/conformal/btcws/cmds.go GetUnconfirmedBalanceCmd.Method 100.00% (1/1)
|
||||||
|
@ -102,11 +102,11 @@ github.com/conformal/btcws/cmds.go parseGetAddressBalanceCmd 72.73% (8/11)
|
||||||
github.com/conformal/btcws/cmds.go GetAddressBalanceCmd.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/cmds.go GetAddressBalanceCmd.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go AccountBalanceNtfn.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/notifications.go AccountBalanceNtfn.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go BlockConnectedNtfn.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/notifications.go BlockConnectedNtfn.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go RescanResultNtfn.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/notifications.go ProcessedTxNtfn.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go WalletLockStateNtfn.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/notifications.go WalletLockStateNtfn.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go TxMinedNtfn.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/notifications.go TxMinedNtfn.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go TxNtfn.UnmarshalJSON 72.73% (8/11)
|
github.com/conformal/btcws/notifications.go TxNtfn.UnmarshalJSON 72.73% (8/11)
|
||||||
github.com/conformal/btcws/notifications.go parseRescanResultNtfn 70.73% (29/41)
|
github.com/conformal/btcws/notifications.go parseProcessedTxNtfn 70.73% (29/41)
|
||||||
github.com/conformal/btcws/notifications.go parseTxMinedNtfn 70.00% (14/20)
|
github.com/conformal/btcws/notifications.go parseTxMinedNtfn 70.00% (14/20)
|
||||||
github.com/conformal/btcws/cmds.go parseCreateEncryptedWalletCmd 69.23% (9/13)
|
github.com/conformal/btcws/cmds.go parseCreateEncryptedWalletCmd 69.23% (9/13)
|
||||||
github.com/conformal/btcws/cmds.go parseNotifySpentCmd 66.67% (10/15)
|
github.com/conformal/btcws/cmds.go parseNotifySpentCmd 66.67% (10/15)
|
||||||
|
@ -138,7 +138,7 @@ github.com/conformal/btcws/notifications.go TxMinedNtfn.SetId 0.00% (0/0)
|
||||||
github.com/conformal/btcws/notifications.go AccountBalanceNtfn.SetId 0.00% (0/0)
|
github.com/conformal/btcws/notifications.go AccountBalanceNtfn.SetId 0.00% (0/0)
|
||||||
github.com/conformal/btcws/notifications.go BlockConnectedNtfn.SetId 0.00% (0/0)
|
github.com/conformal/btcws/notifications.go BlockConnectedNtfn.SetId 0.00% (0/0)
|
||||||
github.com/conformal/btcws/notifications.go BlockDisconnectedNtfn.SetId 0.00% (0/0)
|
github.com/conformal/btcws/notifications.go BlockDisconnectedNtfn.SetId 0.00% (0/0)
|
||||||
github.com/conformal/btcws/notifications.go RescanResultNtfn.SetId 0.00% (0/0)
|
github.com/conformal/btcws/notifications.go ProcessedTxNtfn.SetId 0.00% (0/0)
|
||||||
github.com/conformal/btcws/notifications.go WalletLockStateNtfn.SetId 0.00% (0/0)
|
github.com/conformal/btcws/notifications.go WalletLockStateNtfn.SetId 0.00% (0/0)
|
||||||
github.com/conformal/btcws ---------------------------------------- 75.90% (485/639)
|
github.com/conformal/btcws ---------------------------------------- 75.90% (485/639)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue