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;
}
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;
}
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();
}
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;
}
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);
}
Aggregations