Package org.bitcoinj.utils
Class BlockFileLoader
java.lang.Object
org.bitcoinj.utils.BlockFileLoader
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 Iterable
, BlockFileLoader.BlockFileIterator
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) { }
}
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Iterates all the blocks in a single block file. -
Constructor Summary
ConstructorDescriptionBlockFileLoader
(Network network, File blocksDir) BlockFileLoader
(Network network, List<File> files) BlockFileLoader
(NetworkParameters params, File blocksDir) Deprecated.BlockFileLoader
(NetworkParameters params, List<File> files) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic File
protected Spliterator<ByteBuffer>
fileBlockSpliterator
(File file) protected Stream<ByteBuffer>
fileBlockStream
(File file) getReferenceClientBlockFileList
(File blocksDir) Gets the list of files which contain blocks from Bitcoin Core.iterator()
stream()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BlockFileLoader
-
BlockFileLoader
-
BlockFileLoader
Deprecated. -
BlockFileLoader
Deprecated.
-
-
Method Details