use of io.nuls.consensus.entity.ConsensusStatusInfo in project nuls by nuls-io.
the class ConsensusManager method initConsensusStatusInfo.
public void initConsensusStatusInfo() {
List<Consensus<Agent>> agentList = consensusCacheManager.getCachedAgentList();
ConsensusStatusInfo info = new ConsensusStatusInfo();
for (String address : NulsContext.LOCAL_ADDRESS_LIST) {
if (this.seedNodeList.contains(address)) {
info.setAccount(accountService.getAccount(address));
info.setStatus(ConsensusStatusEnum.IN.getCode());
info.setSeed(true);
break;
}
for (Consensus<Agent> agent : agentList) {
if (agent.getExtend().getPackingAddress().equals(address)) {
info.setAccount(accountService.getAccount(address));
info.setStatus(agent.getExtend().getStatus());
info.setSeed(agent.getExtend().getSeed());
if (ConsensusStatusEnum.NOT_IN.getCode() != info.getStatus()) {
break;
}
}
}
}
if (info.getAccount() == null) {
info.setStatus(ConsensusStatusEnum.NOT_IN.getCode());
}
this.consensusStatusInfo = info;
}
use of io.nuls.consensus.entity.ConsensusStatusInfo in project nuls by nuls-io.
the class PocConsensusModuleBootstrap method getInfo.
@Override
public String getInfo() {
if (this.getStatus() == ModuleStatusEnum.UNINITIALIZED || this.getStatus() == ModuleStatusEnum.INITIALIZING) {
return "";
}
StringBuilder str = new StringBuilder();
str.append("module:[consensus]:\n");
str.append("consensus status:");
ConsensusStatusInfo statusInfo = consensusManager.getConsensusStatusInfo();
if (null == statusInfo) {
str.append(ConsensusStatusEnum.NOT_IN.getText());
} else {
str.append(ConsensusStatusEnum.getConsensusStatusByCode(statusInfo.getStatus()).getText());
}
str.append("\n");
str.append("thread count:");
List<BaseThread> threadList = TaskManager.getThreadList(this.getModuleId());
if (null == threadList) {
str.append(0);
} else {
str.append(threadList.size());
for (BaseThread thread : threadList) {
str.append("\n");
str.append(thread.getName());
str.append("{");
str.append(thread.getPoolName());
str.append("}");
}
}
return str.toString();
}
use of io.nuls.consensus.entity.ConsensusStatusInfo 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