use of org.bcos.channel.dto.EthereumRequest in project web3sdk by FISCO-BCOS.
the class ChannelEthereumService method send.
@Override
public <T extends Response> T send(Request request, Class<T> responseType) throws IOException {
byte[] payload = objectMapper.writeValueAsBytes(request);
EthereumRequest ethereumRequest = new EthereumRequest();
ethereumRequest.setKeyID(channelService.getOrgID());
ethereumRequest.setBankNO("");
ethereumRequest.setContent(new String(payload));
ethereumRequest.setMessageID(channelService.newSeq());
if (timeout != 0) {
ethereumRequest.setTimeout(timeout);
}
EthereumResponse response;
if (!request.isNeedTransCallback()) {
response = channelService.sendEthereumMessage(ethereumRequest);
} else {
response = channelService.sendEthereumMessage(ethereumRequest, request.getTransactionSucCallback());
}
logger.debug("发送ethereum请求:{} {}", ethereumRequest.getMessageID(), objectMapper.writeValueAsString(request));
logger.debug("收到ethereum响应:{} {} {}", ethereumRequest.getMessageID(), response.getErrorCode(), response.getContent());
return objectMapper.readValue(response.getContent(), responseType);
}
Aggregations