use of org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt in project web3sdk by FISCO-BCOS.
the class Service method onReceiveTransactionMessage.
public void onReceiveTransactionMessage(ChannelHandlerContext ctx, BcosMessage message) {
TransactionReceipt receipt = null;
try {
receipt = ObjectMapperFactory.getObjectMapper().readValue(message.getData(), TransactionReceipt.class);
} catch (Exception e) {
receipt = new TransactionReceipt();
receipt.setStatus(String.valueOf(ChannelMessageError.MESSAGE_DECODE_ERROR.getError()));
// error
receipt.setMessage("Decode receipt error: " + e.getLocalizedMessage());
}
onReceiveTransactionMessage(message.getSeq(), receipt);
}
use of org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt in project web3sdk by FISCO-BCOS.
the class ConsensusService method removeNode.
public String removeNode(String nodeId) throws Exception {
List<String> groupPeers = web3j.getGroupPeers().send().getResult();
if (!groupPeers.contains(nodeId)) {
return PrecompiledCommon.transferToJson(PrecompiledCommon.GroupPeers);
}
TransactionReceipt receipt = null;
try {
receipt = removeNodeAndRetReceipt(nodeId);
} catch (RuntimeException e) {
// because the exception is throwed by getTransactionReceipt, we need ignore it.
if (e.getMessage().contains("Don't send requests to this group")) {
return PrecompiledCommon.transferToJson(0);
} else {
throw e;
}
}
return PrecompiledCommon.handleTransactionReceipt(receipt, web3j);
}
use of org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt in project web3sdk by FISCO-BCOS.
the class CRUDService method remove.
public int remove(Table table, Condition condition) throws Exception {
if (table.getKey().length() > PrecompiledCommon.TABLE_KEY_MAX_LENGTH) {
throw new PrecompileMessageException("The value of the table key exceeds the maximum limit(" + PrecompiledCommon.TABLE_KEY_MAX_LENGTH + ").");
}
String conditionStr = ObjectMapperFactory.getObjectMapper().writeValueAsString(condition.getConditions());
TransactionReceipt receipt = crud.remove(table.getTableName(), table.getKey(), conditionStr, table.getOptional()).send();
return PrecompiledCommon.handleTransactionReceiptForCRUD(receipt);
}
use of org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt in project web3sdk by FISCO-BCOS.
the class CRUDService method insert.
public int insert(Table table, Entry entry) throws Exception {
if (table.getKey().length() > PrecompiledCommon.TABLE_KEY_MAX_LENGTH) {
throw new PrecompileMessageException("The value of the table key exceeds the maximum limit(" + PrecompiledCommon.TABLE_KEY_MAX_LENGTH + ").");
}
String entryJsonStr = ObjectMapperFactory.getObjectMapper().writeValueAsString(entry.getFields());
TransactionReceipt receipt = crud.insert(table.getTableName(), table.getKey(), entryJsonStr, table.getOptional()).send();
return PrecompiledCommon.handleTransactionReceiptForCRUD(receipt);
}
use of org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt in project web3sdk by FISCO-BCOS.
the class CRUDService method update.
public int update(Table table, Entry entry, Condition condition) throws Exception {
if (table.getKey().length() > PrecompiledCommon.TABLE_KEY_MAX_LENGTH) {
throw new PrecompileMessageException("The value of the table key exceeds the maximum limit(" + PrecompiledCommon.TABLE_KEY_MAX_LENGTH + ").");
}
String entryJsonStr = ObjectMapperFactory.getObjectMapper().writeValueAsString(entry.getFields());
String conditionStr = ObjectMapperFactory.getObjectMapper().writeValueAsString(condition.getConditions());
TransactionReceipt receipt = crud.update(table.getTableName(), table.getKey(), entryJsonStr, conditionStr, table.getOptional()).send();
return PrecompiledCommon.handleTransactionReceiptForCRUD(receipt);
}
Aggregations