use of io.nuls.core.exception.NulsRuntimeException in project nuls by nuls-io.
the class NodesManager method addNodeToGroup.
public void addNodeToGroup(String groupName, Node node) {
if (!nodeGroups.containsKey(groupName)) {
throw new NulsRuntimeException(ErrorCode.NET_NODE_GROUP_NOT_FOUND);
}
NodeGroup group = nodeGroups.get(groupName);
if (groupName.equals(NetworkConstant.NETWORK_NODE_OUT_GROUP) && group.size() >= network.maxOutCount()) {
return;
}
if (groupName.equals(NetworkConstant.NETWORK_NODE_IN_GROUP) && group.size() >= network.maxInCount()) {
return;
}
node.getGroupSet().add(group.getName());
addNode(node);
group.addNode(node);
}
use of io.nuls.core.exception.NulsRuntimeException in project nuls by nuls-io.
the class NetworkServiceImpl method init.
@Override
public void init() {
try {
connectionManager.init();
nodesManager.init();
} catch (Exception e) {
Log.error(e);
throw new NulsRuntimeException(ErrorCode.NET_SERVER_START_ERROR);
}
}
use of io.nuls.core.exception.NulsRuntimeException in project nuls by nuls-io.
the class UtxoLedgerServiceImpl method getTxList.
@Override
public List<Transaction> getTxList(String address, int txType) throws Exception {
if (StringUtils.isBlank(address) && txType == 0) {
throw new NulsRuntimeException(ErrorCode.PARAMETER_ERROR);
}
List<Transaction> txList = new ArrayList<>();
List<Transaction> cacheTxList = getCacheTxList(address, txType);
txList.addAll(cacheTxList);
if (StringUtils.isNotBlank(address) && NulsContext.LOCAL_ADDRESS_LIST.contains(address)) {
List<TransactionLocalPo> poList = txDao.getLocalTxs(null, address, txType, 0, 0);
for (TransactionLocalPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
} else {
List<TransactionPo> poList = txDao.getTxs(null, address, txType, 0, 0);
for (TransactionPo po : poList) {
txList.add(UtxoTransferTool.toTransaction(po));
}
}
return txList;
}
use of io.nuls.core.exception.NulsRuntimeException in project nuls by nuls-io.
the class AccountTxDaoImpl method rollbackAlias.
@Override
@DbSession
public void rollbackAlias(AliasPo aliasPo) {
try {
AliasPo po = aliasDao.get(aliasPo.getAlias());
if (po != null && po.getAddress().equals(aliasPo.getAddress())) {
aliasDao.delete(aliasPo.getAlias());
AccountPo accountPo = new AccountPo();
po.setAddress(aliasPo.getAddress());
po.setAlias("");
accountDao.updateAlias(accountPo);
}
} catch (Exception e) {
throw new NulsRuntimeException(ErrorCode.DB_ROLLBACK_ERROR);
}
}
use of io.nuls.core.exception.NulsRuntimeException in project nuls by nuls-io.
the class AccountTxDaoImpl method saveAlias.
@DbSession
@Override
public Result saveAlias(AliasPo alias) {
try {
aliasDao.save(alias);
AccountPo po = new AccountPo();
po.setAddress(alias.getAddress());
po.setAlias(alias.getAlias());
accountDao.updateAlias(po);
} catch (Exception e) {
throw new NulsRuntimeException(ErrorCode.DB_SAVE_ERROR);
}
return new Result(true, "OK");
}
Aggregations