@Test public void testCheckIsAfterOrphanChainAndAdd() { testGetBestBlockHeight(); Block block = createBlock(); Block block1 = createBlock(); block1.getHeader().setHeight(1L); block1.getHeader().setPreHash(block.getHeader().getHash()); ChainContainer orphanChain = new ChainContainer(new Chain()); orphanChain.getChain().addBlock(block); chainManager.getOrphanChains().add(orphanChain); assertEquals(1, chainManager.getOrphanChains().size()); boolean success = chainManager.checkIsAfterOrphanChainAndAdd(block1); assertTrue(success); }
public boolean checkIsAfterOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getPreHash().equals(chain.getEndBlockHeader().getHash())) { chain.addBlock(block); return true; } } return false; }
ChainManager { public boolean checkIsAfterOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getPreHash().equals(chain.getEndBlockHeader().getHash())) { chain.addBlock(block); return true; } } return false; } }
ChainManager { public boolean checkIsAfterOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getPreHash().equals(chain.getEndBlockHeader().getHash())) { chain.addBlock(block); return true; } } return false; } ChainManager(); }
ChainManager { public boolean checkIsAfterOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getPreHash().equals(chain.getEndBlockHeader().getHash())) { chain.addBlock(block); return true; } } return false; } ChainManager(); void newOrphanChain(Block block); boolean checkIsBeforeOrphanChainAndAdd(Block block); boolean checkIsAfterOrphanChainAndAdd(Block block); long getBestBlockHeight(); void clear(); ChainContainer getMasterChain(); void setMasterChain(ChainContainer masterChain); List<ChainContainer> getChains(); Block getBestBlock(); List<ChainContainer> getOrphanChains(); }
ChainManager { public boolean checkIsAfterOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getPreHash().equals(chain.getEndBlockHeader().getHash())) { chain.addBlock(block); return true; } } return false; } ChainManager(); void newOrphanChain(Block block); boolean checkIsBeforeOrphanChainAndAdd(Block block); boolean checkIsAfterOrphanChainAndAdd(Block block); long getBestBlockHeight(); void clear(); ChainContainer getMasterChain(); void setMasterChain(ChainContainer masterChain); List<ChainContainer> getChains(); Block getBestBlock(); List<ChainContainer> getOrphanChains();  }