Search in sources :

Example 6 with AliasPo

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;
}
Also used : AliasPo(io.nuls.db.entity.AliasPo)

Example 7 with AliasPo

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();
}
Also used : Address(io.nuls.account.entity.Address) Alias(io.nuls.account.entity.Alias) AliasPo(io.nuls.db.entity.AliasPo)

Example 8 with AliasPo

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);
    }
}
Also used : AccountPo(io.nuls.db.entity.AccountPo) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) AliasPo(io.nuls.db.entity.AliasPo) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) DbSession(io.nuls.db.transactional.annotation.DbSession)

Aggregations

AliasPo (io.nuls.db.entity.AliasPo)8 Alias (io.nuls.account.entity.Alias)3 NulsException (io.nuls.core.exception.NulsException)3 AccountPo (io.nuls.db.entity.AccountPo)3 DbSession (io.nuls.db.transactional.annotation.DbSession)3 Account (io.nuls.account.entity.Account)2 Address (io.nuls.account.entity.Address)1 Result (io.nuls.core.chain.entity.Result)1 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)1 ValidateResult (io.nuls.core.validate.ValidateResult)1