requestRpc method

dynamic requestRpc(
  1. String url,
  2. List params
)

Implementation

requestRpc(String url, List params) async {
  var body = {"jsonrpc": jsonrpc, "id": id};
  body["method"] = url;
  body["params"] = params;
  var response = await http
      .post(_nodeUrl, headers: {'Content-type': 'application/json'}, body: jsonEncode(body))
      .timeout(Duration(seconds: 20), onTimeout: () {
    throw RPCTimeOutException(url);
  });
  id = id + 1;
  if (response.statusCode == 200) {
    return handlerResult(url, body, response.body);
  } else {
    throw RPCRequestException("Request failed with status: ${response.statusCode}.", url);
  }
}