Search in sources :

Example 36 with NulsRuntimeException

use of io.nuls.kernel.exception.NulsRuntimeException in project nuls by nuls-io.

the class DepositTransaction method clone.

@Override
public DepositTransaction clone() {
    DepositTransaction tx = new DepositTransaction();
    try {
        tx.parse(serialize(), 0);
    } catch (Exception e) {
        throw new NulsRuntimeException(e);
    }
    tx.setBlockHeight(blockHeight);
    tx.setStatus(status);
    tx.setHash(hash);
    tx.setSize(size);
    Deposit deposit = tx.getTxData();
    deposit.setBlockHeight(txData.getBlockHeight());
    deposit.setDelHeight(txData.getDelHeight());
    deposit.setTime(txData.getTime());
    deposit.setTxHash(txData.getTxHash());
    deposit.setStatus(txData.getStatus());
    return tx;
}
Also used : Deposit(io.nuls.consensus.poc.protocol.entity.Deposit) NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException) NulsException(io.nuls.kernel.exception.NulsException) NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException)

Example 37 with NulsRuntimeException

use of io.nuls.kernel.exception.NulsRuntimeException in project nuls by nuls-io.

the class AgentStorageServiceImpl method get.

@Override
public AgentPo get(NulsDigestData hash) {
    if (hash == null) {
        return null;
    }
    byte[] body = null;
    try {
        body = dbService.get(ConsensusStorageConstant.DB_NAME_CONSENSUS_AGENT, hash.serialize());
    } catch (IOException e) {
        Log.error(e);
    }
    if (body == null) {
        return null;
    }
    AgentPo agentPo = new AgentPo();
    try {
        agentPo.parse(body, 0);
    } catch (NulsException e) {
        Log.error(e);
        throw new NulsRuntimeException(e);
    }
    agentPo.setHash(hash);
    return agentPo;
}
Also used : NulsException(io.nuls.kernel.exception.NulsException) NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException) IOException(java.io.IOException) AgentPo(io.nuls.consensus.poc.storage.po.AgentPo)

Example 38 with NulsRuntimeException

use of io.nuls.kernel.exception.NulsRuntimeException in project nuls by nuls-io.

the class DepositStorageServiceImpl method save.

@Override
public boolean save(DepositPo depositPo) {
    if (depositPo == null || depositPo.getTxHash() == null) {
        return false;
    }
    byte[] hash;
    try {
        hash = depositPo.getTxHash().serialize();
    } catch (IOException e) {
        Log.error(e);
        throw new NulsRuntimeException(e);
    }
    Result result = null;
    try {
        result = dbService.put(ConsensusStorageConstant.DB_NAME_CONSENSUS_DEPOSIT, hash, depositPo.serialize());
    } catch (IOException e) {
        Log.error(e);
        return false;
    }
    return result.isSuccess();
}
Also used : NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException) IOException(java.io.IOException) Result(io.nuls.kernel.model.Result)

Example 39 with NulsRuntimeException

use of io.nuls.kernel.exception.NulsRuntimeException in project nuls by nuls-io.

the class PunishLogStorageServiceImpl method getPunishList.

@Override
public List<PunishLogPo> getPunishList() {
    List<Entry<byte[], byte[]>> list = dbService.entryList(ConsensusStorageConstant.DB_NAME_CONSENSUS_PUNISH_LOG);
    List<PunishLogPo> polist = new ArrayList<>();
    for (Entry<byte[], byte[]> entry : list) {
        PunishLogPo po = new PunishLogPo();
        try {
            po.parse(entry.getValue(), 0);
        } catch (NulsException e) {
            throw new NulsRuntimeException(e);
        }
        polist.add(po);
    }
    return polist;
}
Also used : Entry(io.nuls.db.model.Entry) NulsException(io.nuls.kernel.exception.NulsException) ArrayList(java.util.ArrayList) NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException) PunishLogPo(io.nuls.consensus.poc.storage.po.PunishLogPo)

Example 40 with NulsRuntimeException

use of io.nuls.kernel.exception.NulsRuntimeException in project nuls by nuls-io.

the class TransactionCacheStorageServiceImpl method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws NulsException {
    dbService.destroyArea(TRANSACTION_CACHE_KEY_NAME);
    Result result = this.dbService.createArea(TRANSACTION_CACHE_KEY_NAME);
    if (result.isFailed() && !DBErrorCode.DB_AREA_EXIST.equals(result.getErrorCode())) {
        throw new NulsRuntimeException(result.getErrorCode());
    }
    startIndex.set(1);
}
Also used : NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException) Result(io.nuls.kernel.model.Result)

Aggregations

NulsRuntimeException (io.nuls.kernel.exception.NulsRuntimeException)68 IOException (java.io.IOException)35 NulsException (io.nuls.kernel.exception.NulsException)26 ArrayList (java.util.ArrayList)21 CoinDataResult (io.nuls.account.ledger.model.CoinDataResult)10 Result (io.nuls.kernel.model.Result)9 Account (io.nuls.account.model.Account)8 MultiSigAccount (io.nuls.account.model.MultiSigAccount)8 Entry (io.nuls.db.model.Entry)8 Agent (io.nuls.consensus.poc.protocol.entity.Agent)7 VarInt (io.nuls.kernel.utils.VarInt)7 CreateAgentTransaction (io.nuls.consensus.poc.protocol.tx.CreateAgentTransaction)6 ValidateResult (io.nuls.kernel.validate.ValidateResult)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 Deposit (io.nuls.consensus.poc.protocol.entity.Deposit)5 DepositTransaction (io.nuls.consensus.poc.protocol.tx.DepositTransaction)5 DepositPo (io.nuls.consensus.poc.storage.po.DepositPo)5 PunishLogPo (io.nuls.consensus.poc.storage.po.PunishLogPo)5 TransferTransaction (io.nuls.protocol.model.tx.TransferTransaction)5 StopAgent (io.nuls.consensus.poc.protocol.entity.StopAgent)4