public class BlockFileLoader extends java.lang.Object implements java.lang.Iterable<Block>, java.util.Iterator<Block>
This class reads block files stored in the Bitcoin Core 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
, this class swallows a lot of IOException
s, 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 Bitcoin Core (version 0.8 or higher) datadir automatically,
try this code fragment:
BlockFileLoader loader = new BlockFileLoader(BlockFileLoader.getReferenceClientBlockFileList());
for (Block block : loader) {
try { chain.add(block); } catch (Exception e) { }
}
Constructor and Description |
---|
BlockFileLoader(NetworkParameters params,
java.io.File blocksDir) |
BlockFileLoader(NetworkParameters params,
java.util.List<java.io.File> files) |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
defaultBlocksDir() |
static java.util.List<java.io.File> |
getReferenceClientBlockFileList() |
static java.util.List<java.io.File> |
getReferenceClientBlockFileList(java.io.File blocksDir)
Gets the list of files which contain blocks from Bitcoin Core.
|
boolean |
hasNext() |
java.util.Iterator<Block> |
iterator() |
Block |
next() |
void |
remove() |
public BlockFileLoader(NetworkParameters params, java.io.File blocksDir)
public BlockFileLoader(NetworkParameters params, java.util.List<java.io.File> files)
public static java.util.List<java.io.File> getReferenceClientBlockFileList(java.io.File blocksDir)
public static java.util.List<java.io.File> getReferenceClientBlockFileList()
public static java.io.File defaultBlocksDir()
public boolean hasNext()
hasNext
in interface java.util.Iterator<Block>
public Block next() throws java.util.NoSuchElementException
next
in interface java.util.Iterator<Block>
java.util.NoSuchElementException
public void remove() throws java.lang.UnsupportedOperationException
remove
in interface java.util.Iterator<Block>
java.lang.UnsupportedOperationException