use of io.nuls.consensus.entity.params.JoinConsensusParam in project nuls by nuls-io.
the class PocConsensusServiceImpl method startConsensus.
@Override
public Transaction startConsensus(String address, String password, Map<String, Object> paramsMap) throws NulsException {
Account account = this.accountService.getAccount(address);
if (null == account) {
throw new NulsRuntimeException(ErrorCode.FAILED, "The account is not exist,address:" + address);
}
if (paramsMap == null || paramsMap.size() < 2) {
throw new NulsRuntimeException(ErrorCode.NULL_PARAMETER);
}
if (!account.validatePassword(password)) {
throw new NulsRuntimeException(ErrorCode.PASSWORD_IS_WRONG);
}
JoinConsensusParam params = new JoinConsensusParam(paramsMap);
if (StringUtils.isNotBlank(params.getIntroduction())) {
Agent agent = new Agent();
agent.setPackingAddress(params.getPackingAddress());
agent.setDeposit(Na.valueOf(params.getDeposit()));
agent.setIntroduction(params.getIntroduction());
agent.setSeed(params.isSeed());
agent.setCommissionRate(params.getCommissionRate());
agent.setAgentName(params.getAgentName());
try {
return this.registerAgent(agent, account, password);
} catch (IOException e) {
throw new NulsRuntimeException(e);
}
}
try {
return this.joinTheConsensus(account, password, params.getDeposit(), params.getAgentHash());
} catch (IOException e) {
throw new NulsRuntimeException(e);
}
}
Aggregations