Search in sources :

Example 41 with Result

use of io.nuls.kernel.model.Result in project nuls by nuls-io.

the class AgentStorageServiceImpl method save.

@Override
public boolean save(AgentPo agentPo) {
    if (agentPo == null || agentPo.getHash() == null) {
        return false;
    }
    byte[] hash;
    try {
        hash = agentPo.getHash().serialize();
    } catch (IOException e) {
        Log.error(e);
        throw new NulsRuntimeException(e);
    }
    Result result = null;
    try {
        result = dbService.put(ConsensusStorageConstant.DB_NAME_CONSENSUS_AGENT, hash, agentPo.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 42 with Result

use of io.nuls.kernel.model.Result in project nuls by nuls-io.

the class TransactionCacheStorageServiceImpl method putTx.

@Override
public boolean putTx(Transaction tx) {
    if (tx == null) {
        return false;
    }
    byte[] txHashBytes = null;
    try {
        txHashBytes = tx.getHash().serialize();
    } catch (IOException e) {
        Log.error(e);
        return false;
    }
    // 保存交易
    Result result = null;
    try {
        result = dbService.put(TRANSACTION_CACHE_KEY_NAME, txHashBytes, tx.serialize());
    } catch (IOException e) {
        Log.error(e);
        return false;
    }
    // result = dbService.put(TRANSACTION_CACHE_KEY_NAME, LAST_KEY, lastIndexBytes);
    return result.isSuccess();
}
Also used : IOException(java.io.IOException) Result(io.nuls.kernel.model.Result)

Example 43 with Result

use of io.nuls.kernel.model.Result in project nuls by nuls-io.

the class UtxoAccountsStorageServiceImpl method saveHadSynBlockHeight.

@Override
public Result saveHadSynBlockHeight(long height) {
    UtxoAccountsSynInfo utxoAccountsSynInfo = new UtxoAccountsSynInfo(height);
    utxoAccountsSynInfo.setUpdateTimeMillion(System.currentTimeMillis());
    Result result = dbService.putModel(UtxoAccountsStorageConstant.DB_NAME_UTXO_ACCOUNTS_BLOCK_CACHE, UtxoAccountsStorageConstant.DB_NAME_UTXO_ACCOUNTS_BLOCK_SYN_KEY, utxoAccountsSynInfo);
    return result;
}
Also used : UtxoAccountsSynInfo(io.nuls.utxo.accounts.storage.po.UtxoAccountsSynInfo) Result(io.nuls.kernel.model.Result)

Example 44 with Result

use of io.nuls.kernel.model.Result in project nuls by nuls-io.

the class RegisterAgentProcessTest method testOnRollback.

@Test
public void testOnRollback() {
    assertNotNull(tx);
    assertNotNull(registerAgentProcess);
    testOnCommit();
    Result result = registerAgentProcess.onRollback(tx, null);
    assert (result.isSuccess());
}
Also used : ValidateResult(io.nuls.kernel.validate.ValidateResult) Result(io.nuls.kernel.model.Result) Test(org.junit.Test) BaseTest(io.nuls.consensus.poc.BaseTest)

Example 45 with Result

use of io.nuls.kernel.model.Result 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)

Aggregations

Result (io.nuls.kernel.model.Result)70 NulsException (io.nuls.kernel.exception.NulsException)16 IOException (java.io.IOException)15 NulsRuntimeException (io.nuls.kernel.exception.NulsRuntimeException)12 ValidateResult (io.nuls.kernel.validate.ValidateResult)11 AccountPo (io.nuls.account.storage.po.AccountPo)7 RpcClientResult (io.nuls.kernel.model.RpcClientResult)7 ArrayList (java.util.ArrayList)7 Account (io.nuls.account.model.Account)6 NulsDigestData (io.nuls.kernel.model.NulsDigestData)5 Test (org.junit.Test)5 CryptoException (io.nuls.core.tools.crypto.Exception.CryptoException)4 BatchOperation (io.nuls.db.service.BatchOperation)4 Address (io.nuls.kernel.model.Address)4 Block (io.nuls.kernel.model.Block)4 BlockHeader (io.nuls.kernel.model.BlockHeader)4 Transaction (io.nuls.kernel.model.Transaction)4 Node (io.nuls.network.model.Node)4 NotFound (io.nuls.protocol.model.NotFound)4 ApiOperation (io.swagger.annotations.ApiOperation)4