Search in sources :

Example 6 with AgentPo

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);
}
Also used : Account(io.nuls.account.entity.Account) Agent(io.nuls.consensus.entity.member.Agent) Deposit(io.nuls.consensus.entity.member.Deposit) DepositPo(io.nuls.db.entity.DepositPo) Consensus(io.nuls.consensus.entity.Consensus) AgentPo(io.nuls.db.entity.AgentPo) ConsensusStatusInfo(io.nuls.consensus.entity.ConsensusStatusInfo)

Aggregations

AgentPo (io.nuls.db.entity.AgentPo)6 Agent (io.nuls.consensus.entity.member.Agent)3 Deposit (io.nuls.consensus.entity.member.Deposit)3 DepositPo (io.nuls.db.entity.DepositPo)3 EventBroadcaster (io.nuls.event.bus.service.intf.EventBroadcaster)3 HashMap (java.util.HashMap)3 Account (io.nuls.account.entity.Account)1 Consensus (io.nuls.consensus.entity.Consensus)1 ConsensusStatusInfo (io.nuls.consensus.entity.ConsensusStatusInfo)1 PocExitConsensusTransaction (io.nuls.consensus.entity.tx.PocExitConsensusTransaction)1 PocJoinConsensusTransaction (io.nuls.consensus.entity.tx.PocJoinConsensusTransaction)1 RegisterAgentTransaction (io.nuls.consensus.entity.tx.RegisterAgentTransaction)1 CancelConsensusNotice (io.nuls.consensus.event.notice.CancelConsensusNotice)1 EntrustConsensusNotice (io.nuls.consensus.event.notice.EntrustConsensusNotice)1 RegisterAgentNotice (io.nuls.consensus.event.notice.RegisterAgentNotice)1 StopConsensusNotice (io.nuls.consensus.event.notice.StopConsensusNotice)1 Transaction (io.nuls.core.chain.entity.Transaction)1 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)1 RpcResult (io.nuls.rpc.entity.RpcResult)1