Add reply parser for GetBestBlockCmd.
This commit is contained in:
parent
e12673df11
commit
c24be8b7bf
1 changed files with 13 additions and 2 deletions
15
cmds.go
15
cmds.go
|
@ -29,8 +29,8 @@ func init() {
|
||||||
parseExportWatchingWalletCmd, nil, `TODO(jrick) fillmein`)
|
parseExportWatchingWalletCmd, nil, `TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("getaddressbalance",
|
btcjson.RegisterCustomCmd("getaddressbalance",
|
||||||
parseGetAddressBalanceCmd, nil, `TODO(jrick) fillmein`)
|
parseGetAddressBalanceCmd, nil, `TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("getbestblock", parseGetBestBlockCmd, nil,
|
btcjson.RegisterCustomCmd("getbestblock", parseGetBestBlockCmd,
|
||||||
`TODO(jrick) fillmein`)
|
parseGetBestBlockCmdReply, `TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("getcurrentnet", parseGetCurrentNetCmd, nil,
|
btcjson.RegisterCustomCmd("getcurrentnet", parseGetCurrentNetCmd, nil,
|
||||||
`TODO(jrick) fillmein`)
|
`TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("getunconfirmedbalance",
|
btcjson.RegisterCustomCmd("getunconfirmedbalance",
|
||||||
|
@ -489,6 +489,17 @@ func parseGetBestBlockCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
return NewGetBestBlockCmd(r.Id), nil
|
return NewGetBestBlockCmd(r.Id), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parseGetBestBlockCmdReply parses a the reply to a GetBestBlockCmd into a
|
||||||
|
// concrete type and returns it packed into an interface. This is used when
|
||||||
|
// registering the custom command with btcjson.
|
||||||
|
func parseGetBestBlockCmdReply(message json.RawMessage) (interface{}, error) {
|
||||||
|
var res *GetBestBlockResult
|
||||||
|
if err := json.Unmarshal(message, &res); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Id satisifies the Cmd interface by returning the ID of the command.
|
// Id satisifies the Cmd interface by returning the ID of the command.
|
||||||
func (cmd *GetBestBlockCmd) Id() interface{} {
|
func (cmd *GetBestBlockCmd) Id() interface{} {
|
||||||
return cmd.id
|
return cmd.id
|
||||||
|
|
Loading…
Add table
Reference in a new issue