Svarog 171deded4e
Implement GetBlocks RPC command (#1514)
* Remove BlockHexes from GetBlocks request and response

* Add GetBlocks RPC

* Include the selectedTip's anticone in GetBlocks

* Add Anticone to fakeRelayInvsContext

* Include verbose data only if it was requested + Add comments to HandleGetBlocks

* Allow antiPastHashesBetween to receive unrelated low and high hashes

* Convert to/from protowire GetBlocksResponse with no verbose data correctly

* Removed NextLowHash

* Update GetBlocks in rpc_client

* Validate in consensus.Anticone that blockHash exists

Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
2021-02-10 18:27:04 +02:00

24 lines
862 B
Go

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