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