com.google.bitcoin.utils
Class BlockFileLoader
java.lang.Object
com.google.bitcoin.utils.BlockFileLoader
- All Implemented Interfaces:
- Iterable<Block>, Iterator<Block>
public class BlockFileLoader
- extends Object
- implements Iterable<Block>, Iterator<Block>
This class reads block files stored in the reference/Satoshi client format. This is simply a way to concatenate
blocks together. Importing block data with this tool can be a lot faster than syncing over the network, if you
have the files available.
In order to comply with Iterator<Block>, this class swallows a lot of IOExceptions, which may result in a few
blocks being missed followed by a huge set of orphan blocks.
To blindly import all files which can be found in a reference client (version >= 0.8) datadir automatically,
try this code fragment:
BlockFileLoader loader = new BlockFileLoader(BlockFileLoader.getReferenceClientBlockFileList());
for (Block block : loader) {
try { chain.add(block); } catch (Exception e) { }
}
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BlockFileLoader
public BlockFileLoader(NetworkParameters params,
List<File> files)
getReferenceClientBlockFileList
public static List<File> getReferenceClientBlockFileList()
- Gets the list of files which contain blocks from the Satoshi client.
hasNext
public boolean hasNext()
- Specified by:
hasNext in interface Iterator<Block>
next
public Block next()
throws NoSuchElementException
- Specified by:
next in interface Iterator<Block>
- Throws:
NoSuchElementException
remove
public void remove()
throws UnsupportedOperationException
- Specified by:
remove in interface Iterator<Block>
- Throws:
UnsupportedOperationException
iterator
public Iterator<Block> iterator()
- Specified by:
iterator in interface Iterable<Block>
Copyright © 2014. All rights reserved.