use of io.nuls.db.entity.AgentPo in project nuls by nuls-io.
the class ConsensusCacheManager method init.
public void init() {
Account self = accountService.getDefaultAccount();
List<DepositPo> depositPoList = this.depositDao.getList();
List<AgentPo> agentPoList = this.agentDao.getList();
Consensus mine = null;
for (AgentPo po : agentPoList) {
Consensus<Agent> ca = ConsensusTool.fromPojo(po);
this.cacheAgent(ca);
if (null != self && ca.getAddress().equals(self.getAddress().toString())) {
mine = ca;
}
}
for (DepositPo dpo : depositPoList) {
Consensus<Deposit> cd = ConsensusTool.fromPojo(dpo);
this.cacheDeposit(cd);
if (null != self && null == mine && cd.getAddress().equals(self.getAddress().toString())) {
mine = cd;
}
}
if (null == self) {
return;
}
ConsensusStatusInfo info = new ConsensusStatusInfo();
info.setAccount(self);
if (null == mine) {
info.setStatus(ConsensusStatusEnum.NOT_IN.getCode());
} else if (mine.getExtend() instanceof Agent) {
info.setSeed(((Agent) mine.getExtend()).getSeed());
info.setStatus(((Agent) mine.getExtend()).getStatus());
}
this.updateConsensusStatusInfo(info);
}
Aggregations