use of io.nuls.db.entity.AliasPo in project nuls by nuls-io.
the class AccountTool method toAliasPojo.
public static AliasPo toAliasPojo(Alias alias) {
AliasPo po = new AliasPo();
po.setAddress(alias.getAddress());
po.setAlias(alias.getAlias());
po.setStatus(alias.getStatus());
return po;
}
use of io.nuls.db.entity.AliasPo in project nuls by nuls-io.
the class AliasValidator method validate.
@Override
public ValidateResult validate(AliasTransaction tx) {
Alias alias = tx.getTxData();
if (StringUtils.isBlank(alias.getAddress()) || new Address(alias.getAddress()).getHash().length != 23) {
return ValidateResult.getFailedResult("The address format error");
}
if (!StringUtils.validAlias(alias.getAlias())) {
return ValidateResult.getFailedResult("The alias is between 3 to 20 characters");
}
AliasPo aliasPo = getAliasDataService().get(alias.getAlias());
if (aliasPo != null) {
return ValidateResult.getFailedResult("The alias has been occupied");
}
return ValidateResult.getSuccessResult();
}
use of io.nuls.db.entity.AliasPo in project nuls by nuls-io.
the class AccountTxDaoImpl method rollbackAlias.
@Override
@DbSession
public void rollbackAlias(AliasPo aliasPo) {
try {
AliasPo po = aliasDao.get(aliasPo.getAlias());
if (po != null && po.getAddress().equals(aliasPo.getAddress())) {
aliasDao.delete(aliasPo.getAlias());
AccountPo accountPo = new AccountPo();
po.setAddress(aliasPo.getAddress());
po.setAlias("");
accountDao.updateAlias(accountPo);
}
} catch (Exception e) {
throw new NulsRuntimeException(ErrorCode.DB_ROLLBACK_ERROR);
}
}
Aggregations