Search in sources :

Example 46 with NulsException

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

the class DepositStorageServiceImpl method get.

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

Example 47 with NulsException

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

the class DepositStorageServiceImpl method getList.

@Override
public List<DepositPo> getList() {
    List<Entry<byte[], byte[]>> list = dbService.entryList(ConsensusStorageConstant.DB_NAME_CONSENSUS_DEPOSIT);
    List<DepositPo> resultList = new ArrayList<>();
    if (list == null) {
        return resultList;
    }
    for (Entry<byte[], byte[]> entry : list) {
        DepositPo depositPo = new DepositPo();
        try {
            depositPo.parse(entry.getValue(), 0);
        } catch (NulsException e) {
            Log.error(e);
            throw new NulsRuntimeException(e);
        }
        NulsDigestData hash = new NulsDigestData();
        try {
            hash.parse(entry.getKey(), 0);
        } catch (NulsException e) {
            Log.error(e);
        }
        depositPo.setTxHash(hash);
        resultList.add(depositPo);
    }
    return resultList;
}
Also used : Entry(io.nuls.db.model.Entry) DepositPo(io.nuls.consensus.poc.storage.po.DepositPo) NulsException(io.nuls.kernel.exception.NulsException) ArrayList(java.util.ArrayList) NulsRuntimeException(io.nuls.kernel.exception.NulsRuntimeException) NulsDigestData(io.nuls.kernel.model.NulsDigestData)

Example 48 with NulsException

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

the class RandomSeedsStorageServiceImpl method getSeed.

@Override
public RandomSeedPo getSeed(long height) {
    byte[] bytes = dbService.get(ConsensusStorageConstant.DB_NAME_RANDOM_SEEDS, SerializeUtils.uint64ToByteArray(height));
    if (null == bytes) {
        return null;
    }
    RandomSeedPo po = new RandomSeedPo();
    try {
        po.parse(new NulsByteBuffer(bytes, 0));
        po.setHeight(height);
    } catch (NulsException e) {
        Log.error(e);
    }
    return po;
}
Also used : RandomSeedPo(io.nuls.consensus.poc.storage.po.RandomSeedPo) NulsException(io.nuls.kernel.exception.NulsException) NulsByteBuffer(io.nuls.kernel.utils.NulsByteBuffer)

Example 49 with NulsException

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

the class RandomSeedsStorageServiceImpl method getAddressStatus.

@Override
public RandomSeedStatusPo getAddressStatus(byte[] address) {
    byte[] bytes = dbService.get(ConsensusStorageConstant.DB_NAME_RANDOM_SEEDS, address);
    if (null == bytes) {
        return null;
    }
    RandomSeedStatusPo po = new RandomSeedStatusPo();
    try {
        po.parse(new NulsByteBuffer(bytes, 0));
        po.setAddress(address);
    } catch (NulsException e) {
        Log.error(e);
    }
    return po;
}
Also used : NulsException(io.nuls.kernel.exception.NulsException) RandomSeedStatusPo(io.nuls.consensus.poc.storage.po.RandomSeedStatusPo) NulsByteBuffer(io.nuls.kernel.utils.NulsByteBuffer)

Example 50 with NulsException

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

the class OrphanStorageServiceImpl method get.

@Override
public Block get(NulsDigestData key) {
    assert (key != null);
    byte[] content = dbService.get(DB_NAME, key.getDigestBytes());
    Block block = new Block();
    try {
        block.parse(content, 0);
    } catch (NulsException e) {
        Log.error(e);
    }
    return block;
}
Also used : NulsException(io.nuls.kernel.exception.NulsException) Block(io.nuls.kernel.model.Block)

Aggregations

NulsException (io.nuls.kernel.exception.NulsException)109 IOException (java.io.IOException)35 Account (io.nuls.account.model.Account)25 ValidateResult (io.nuls.kernel.validate.ValidateResult)23 ECKey (io.nuls.core.tools.crypto.ECKey)20 CoinDataResult (io.nuls.account.ledger.model.CoinDataResult)18 NulsRuntimeException (io.nuls.kernel.exception.NulsRuntimeException)16 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14 TransferTransaction (io.nuls.protocol.model.tx.TransferTransaction)13 Coin (io.nuls.kernel.model.Coin)12 MultiSigAccount (io.nuls.account.model.MultiSigAccount)11 ContractResult (io.nuls.contract.dto.ContractResult)9 NulsByteBuffer (io.nuls.kernel.utils.NulsByteBuffer)9 ArrayList (java.util.ArrayList)9 TransactionSignature (io.nuls.kernel.script.TransactionSignature)8 BigInteger (java.math.BigInteger)8 TransactionDataResult (io.nuls.account.ledger.model.TransactionDataResult)7 AccountPo (io.nuls.account.storage.po.AccountPo)7 AliasPo (io.nuls.account.storage.po.AliasPo)7 CryptoException (io.nuls.core.tools.crypto.Exception.CryptoException)7