@Test public void testInitRound() { assertNotNull(roundManager); assertNotNull(roundManager.getChain()); Chain chain = roundManager.getChain(); assertNotNull(chain.getEndBlockHeader()); assert(chain.getAllBlockList().size() > 0); MeetingRound round = roundManager.initRound(); assertNotNull(round); assertEquals(round.getIndex(), 2L); Assert.assertEquals(round.getStartTime(), ProtocolConstant.BLOCK_TIME_INTERVAL_MILLIS + 1L); MeetingRound round2 = roundManager.getNextRound(null, false); assertNotNull(round2); assertEquals(round.getIndex(), round2.getIndex()); assertEquals(round.getStartTime(), round2.getStartTime()); round2 = roundManager.getNextRound(null, true); assertNotNull(round2); assert(round.getIndex() < round2.getIndex()); assert(round.getStartTime() < round2.getStartTime()); assertEquals("", 0d, round2.getTotalWeight(), 2200000d); }
public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; }
RoundManager { public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; } }
RoundManager { public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; } RoundManager(Chain chain); }
RoundManager { public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }
RoundManager { public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService();  }