@Test public void badDifficulty() throws Exception { assertTrue(testNetChain.add(getBlock1())); Block b2 = getBlock2(); assertTrue(testNetChain.add(b2)); Block bad = new Block(TESTNET, Block.BLOCK_VERSION_GENESIS); bad.setMerkleRoot(Sha256Hash.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); bad.setNonce(140548933); bad.setTime(1279242649); bad.setPrevBlockHash(b2.getHash()); bad.setDifficultyTarget(Block.EASIEST_DIFFICULTY_TARGET); try { testNetChain.add(bad); fail(); } catch (VerificationException e) { assertTrue(e.getMessage(), e.getCause().getMessage().contains("Difficulty target is bad")); } BigInteger oldVal = TESTNET.getMaxTarget(); TESTNET.setMaxTarget(new BigInteger("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)); try { testNetChain.add(bad); fail(); } catch (VerificationException e) { assertTrue(e.getMessage(), e.getCause().getMessage().contains("Unexpected change in difficulty")); } TESTNET.setMaxTarget(oldVal); }
@Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; }
BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } }
BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } BlockChain(Context context, Wallet wallet, BlockStore blockStore);  BlockChain(NetworkParameters params, Wallet wallet, BlockStore blockStore);  BlockChain(Context context, BlockStore blockStore);  BlockChain(NetworkParameters params, BlockStore blockStore);  BlockChain(Context params, List<? extends Wallet> wallets, BlockStore blockStore);  BlockChain(NetworkParameters params, List<? extends Wallet> wallets, BlockStore blockStore); }
BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } BlockChain(Context context, Wallet wallet, BlockStore blockStore);  BlockChain(NetworkParameters params, Wallet wallet, BlockStore blockStore);  BlockChain(Context context, BlockStore blockStore);  BlockChain(NetworkParameters params, BlockStore blockStore);  BlockChain(Context params, List<? extends Wallet> wallets, BlockStore blockStore);  BlockChain(NetworkParameters params, List<? extends Wallet> wallets, BlockStore blockStore); @Override boolean add(FilteredBlock block); }
BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } BlockChain(Context context, Wallet wallet, BlockStore blockStore);  BlockChain(NetworkParameters params, Wallet wallet, BlockStore blockStore);  BlockChain(Context context, BlockStore blockStore);  BlockChain(NetworkParameters params, BlockStore blockStore);  BlockChain(Context params, List<? extends Wallet> wallets, BlockStore blockStore);  BlockChain(NetworkParameters params, List<? extends Wallet> wallets, BlockStore blockStore); @Override boolean add(FilteredBlock block);  }