Svarog fb11981da1
Make kaspactl usable by human beings (#1452)
* Add request_types and their help

* Added command parser

* Updated main to use command if it's specified

* Some progress in making everything work

* Fix command parser for pointers to structs

* Cleanup code

* Enhance usage text

* Fixed typo

* Some minor style fixing, and remove temporary code

* Correctly fallthrough in stringToValue unsupported types

Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
2021-01-26 14:22:35 +02:00

24 lines
792 B
Go

package rpcclient
import "github.com/kaspanet/kaspad/app/appmessage"
// GetBlock sends an RPC request respective to the function's name and returns the RPC server's response
func (c *RPCClient) GetBlock(hash string, includeTransactionVerboseData bool) (
*appmessage.GetBlockResponseMessage, error) {
err := c.rpcRouter.outgoingRoute().Enqueue(
appmessage.NewGetBlockRequestMessage(hash, includeTransactionVerboseData))
if err != nil {
return nil, err
}
response, err := c.route(appmessage.CmdGetBlockResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return nil, err
}
GetBlockResponse := response.(*appmessage.GetBlockResponseMessage)
if GetBlockResponse.Error != nil {
return nil, c.convertRPCError(GetBlockResponse.Error)
}
return GetBlockResponse, nil
}