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) { }
}
| Constructor and Description |
|---|
BlockFileLoader(NetworkParameters params,
List<File> files) |
| Modifier and Type | Method and Description |
|---|---|
static List<File> |
getReferenceClientBlockFileList()
Gets the list of files which contain blocks from the Satoshi client.
|
boolean |
hasNext() |
Iterator<Block> |
iterator() |
Block |
next() |
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorforEachRemainingpublic BlockFileLoader(NetworkParameters params, List<File> files)
public static List<File> getReferenceClientBlockFileList()
public Block next() throws NoSuchElementException
next in interface Iterator<Block>NoSuchElementExceptionpublic void remove()
throws UnsupportedOperationException
remove in interface Iterator<Block>UnsupportedOperationExceptionCopyright © 2015. All rights reserved.