org.bitcoinj.utils.BlockFileLoader Java Examples

The following examples show how to use org.bitcoinj.utils.BlockFileLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractFullPrunedBlockChainTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFirst100KBlocks() throws Exception {
    Context context = new Context(MAINNET);
    File blockFile = new File(getClass().getResource("first-100k-blocks.dat").getFile());
    BlockFileLoader loader = new BlockFileLoader(MAINNET, Arrays.asList(blockFile));

    store = createStore(MAINNET, 10);
    resetStore(store);
    chain = new FullPrunedBlockChain(context, store);
    for (Block block : loader)
        chain.add(block);
    try {
        store.close();
    } catch (Exception e) {
    }
}
 
Example #2
Source File: AbstractFullPrunedBlockChainTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFirst100KBlocks() throws Exception {
    NetworkParameters params = MainNetParams.get();
    Context context = new Context(params);
    File blockFile = new File(getClass().getResource("first-100k-blocks.dat").getFile());
    BlockFileLoader loader = new BlockFileLoader(params, Arrays.asList(blockFile));
    
    store = createStore(params, 10);
    resetStore(store);
    chain = new FullPrunedBlockChain(context, store);
    for (Block block : loader)
        chain.add(block);
    try {
        store.close();
    } catch (Exception e) {}
}
 
Example #3
Source File: AbstractFullPrunedBlockChainTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFirst100KBlocks() throws Exception {
    NetworkParameters params = MainNetParams.get();
    Context context = new Context(params);
    File blockFile = new File(getClass().getResource("first-100k-blocks.dat").getFile());
    BlockFileLoader loader = new BlockFileLoader(params, Arrays.asList(blockFile));
    
    store = createStore(params, 10);
    resetStore(store);
    chain = new FullPrunedBlockChain(context, store);
    for (Block block : loader)
        chain.add(block);
    try {
        store.close();
    } catch (Exception e) {}
}
 
Example #4
Source File: BlockImporter.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException {
    System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]");
    System.out.println("       blockStore is required unless type is Mem or MemFull");
    System.out.println("       eg BlockImporter prod H2 /home/user/bitcoinj.h2store");
    System.out.println("       Does full verification if the store supports it");
    Preconditions.checkArgument(args.length == 2 || args.length == 3);
    
    NetworkParameters params;
    if (args[0].equals("test"))
        params = TestNet3Params.get();
    else
        params = MainNetParams.get();
    
    BlockStore store;
    if (args[1].equals("H2")) {
        Preconditions.checkArgument(args.length == 3);
        store = new H2FullPrunedBlockStore(params, args[2], 100);
    } else if (args[1].equals("MemFull")) {
        Preconditions.checkArgument(args.length == 2);
        store = new MemoryFullPrunedBlockStore(params, 100);
    } else if (args[1].equals("Mem")) {
        Preconditions.checkArgument(args.length == 2);
        store = new MemoryBlockStore(params);
    } else if (args[1].equals("SPV")) {
        Preconditions.checkArgument(args.length == 3);
        store = new SPVBlockStore(params, new File(args[2]));
    } else {
        System.err.println("Unknown store " + args[1]);
        return;
    }
    
    AbstractBlockChain chain = null;
    if (store instanceof FullPrunedBlockStore)
        chain = new FullPrunedBlockChain(params, (FullPrunedBlockStore) store);
    else
        chain = new BlockChain(params, store);
    
    BlockFileLoader loader = new BlockFileLoader(params, BlockFileLoader.getReferenceClientBlockFileList());
    
    for (Block block : loader)
        chain.add(block);
}
 
Example #5
Source File: BlockImporter.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException {
    System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]");
    System.out.println("       blockStore is required unless type is Mem or MemFull");
    System.out.println("       eg BlockImporter prod H2 /home/user/bitcoinj.h2store");
    System.out.println("       Does full verification if the store supports it");
    Preconditions.checkArgument(args.length == 2 || args.length == 3);
    
    NetworkParameters params;
    if (args[0].equals("test"))
        params = TestNet3Params.get();
    else
        params = MainNetParams.get();
    
    BlockStore store;
    if (args[1].equals("H2")) {
        Preconditions.checkArgument(args.length == 3);
        store = new H2FullPrunedBlockStore(params, args[2], 100);
    } else if (args[1].equals("MemFull")) {
        Preconditions.checkArgument(args.length == 2);
        store = new MemoryFullPrunedBlockStore(params, 100);
    } else if (args[1].equals("Mem")) {
        Preconditions.checkArgument(args.length == 2);
        store = new MemoryBlockStore(params);
    } else if (args[1].equals("SPV")) {
        Preconditions.checkArgument(args.length == 3);
        store = new SPVBlockStore(params, new File(args[2]));
    } else {
        System.err.println("Unknown store " + args[1]);
        return;
    }
    
    AbstractBlockChain chain = null;
    if (store instanceof FullPrunedBlockStore)
        chain = new FullPrunedBlockChain(params, (FullPrunedBlockStore) store);
    else
        chain = new BlockChain(params, store);
    
    BlockFileLoader loader = new BlockFileLoader(params, BlockFileLoader.getReferenceClientBlockFileList());
    
    for (Block block : loader)
        chain.add(block);
}