Search in sources :

Example 46 with NulsRuntimeException

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);
}
Also used : NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) NodeGroup(io.nuls.network.entity.NodeGroup)

Example 47 with NulsRuntimeException

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);
    }
}
Also used : NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException)

Example 48 with NulsRuntimeException

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;
}
Also used : TransferTransaction(io.nuls.ledger.entity.tx.TransferTransaction) AbstractCoinTransaction(io.nuls.ledger.entity.tx.AbstractCoinTransaction) LockNulsTransaction(io.nuls.ledger.entity.tx.LockNulsTransaction) TransactionLocalPo(io.nuls.db.entity.TransactionLocalPo) ArrayList(java.util.ArrayList) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) TransactionPo(io.nuls.db.entity.TransactionPo)

Example 49 with NulsRuntimeException

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);
    }
}
Also used : AccountPo(io.nuls.db.entity.AccountPo) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) AliasPo(io.nuls.db.entity.AliasPo) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) DbSession(io.nuls.db.transactional.annotation.DbSession)

Example 50 with NulsRuntimeException

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");
}
Also used : AccountPo(io.nuls.db.entity.AccountPo) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) Result(io.nuls.core.chain.entity.Result) DbSession(io.nuls.db.transactional.annotation.DbSession)

Aggregations

NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)64 NulsException (io.nuls.core.exception.NulsException)26 IOException (java.io.IOException)11 Transaction (io.nuls.core.chain.entity.Transaction)10 ArrayList (java.util.ArrayList)9 Account (io.nuls.account.entity.Account)7 AbstractNulsQueue (io.nuls.core.utils.queue.intf.AbstractNulsQueue)7 DbSession (io.nuls.db.transactional.annotation.DbSession)6 CoinTransferData (io.nuls.ledger.entity.params.CoinTransferData)5 ValidateResult (io.nuls.core.validate.ValidateResult)4 Coin (io.nuls.ledger.entity.params.Coin)4 TransactionEvent (io.nuls.ledger.event.TransactionEvent)4 AccountService (io.nuls.account.service.intf.AccountService)3 Block (io.nuls.core.chain.entity.Block)3 AccountPo (io.nuls.db.entity.AccountPo)3 AbstractCoinTransaction (io.nuls.ledger.entity.tx.AbstractCoinTransaction)3 BlockHashResponse (io.nuls.consensus.entity.BlockHashResponse)2 RedPunishData (io.nuls.consensus.entity.RedPunishData)2 BestCorrectBlock (io.nuls.consensus.entity.block.BestCorrectBlock)2 Agent (io.nuls.consensus.entity.member.Agent)2