# Import/Export Blockchain
A running node requires up-to-date blockchain database for operation. You can speed up (by ~10%) your blockchain synchronization by importing blockchain from binary file rather than synchronizing your blockchain state during regular node operation. Binary files contain chain of transaction blocks in verifiable format (include the original sequence of all the transactions with signatures and blocks with signatures of the block generators).
If you have a running Waves node that is synchronized to current state, you can export your blockchain to a binary file.
# Import Blockchain from Binary File
Importing blockchain from binary file causes CPU load and can take 1-3 days to complete. The process implies the same execution of every transaction that happens during normal node operation. That includes validation of signatures, balances etc.
To import blockchain, do the following:
Download the binary file (for example,
mainnet_last
for Mainnet) from one of the links below:Mainnet: http://blockchain.wavesnodes.com/
Stop the node with
service waves stop
command.Empty the existing directory where the node's database is stored. By default, the database is stored in
data
subdirectory of the base application directory (in particular, in/var/lib/waves/data
for a node installed from a DEB package).Linux console command
sudo rm -rdf /var/lib/waves/data
.Execute the following command:
Windows
java -cp waves-all-<version>.jar com.wavesplatform.Importer -c <configuration-file-name> -i <binary-file-name>
Linux
Mainnet:
sudo -u waves waves import -c /etc/waves/waves.conf -i <binary-file-name>
Testnet:
sudo -u waves-testnet waves-testnet import -c /etc/waves-testnet/waves.conf -i <binary-file-name>
macOS
java -cp waves-all-<version>.jar com.wavesplatform.Importer -c <configuration-file-name> -i <binary-file-name>
Use the name of the desired binary file instead of
binary-file-name
.
Note: You can speed up the import by 5-20% at your own risk. To do so, use -no-verify
option of the Importer
parameter to turn off block and transaction validation. Use with caution and only if you trust the blockchain binary file.
# Import Blockchain Up to a Certain Height
It is possible to set target height. If the height
parameter is not set, all the blocks will be imported.
To import blockchain up to a certain height, do the following:
Stop the node with
service waves stop
command.Empty the existing directory where the node's database is stored.
Execute the following command:
Windows
java com.wavesplatform.Importer -c <configuration-file-name> -i <blockchain_file> -h <height>
Linux
Mainnet:
sudo -u waves waves import -c /etc/waves/waves.conf -i <blockchain_file> -h <height>
Testnet:
sudo -u waves-testnet waves-testnet import -c /etc/waves-testnet/waves.conf -i <blockchain_file> -h <height>
macOS
java com.wavesplatform.Importer -c <configuration-file-name> -i <blockchain_file> -h <height>
# Export Blockchain to Binary File
If you have a running Waves node that is synchronized to current state, you can export the node's blockchain to a binary file. Exporting is quite a fast operation, but the resulting binary file can take up to 1/3 of the database directory size.
To export the existing blockchain to a binary file, do the following:
Stop the node with
service waves stop
command.Execute the following command:
Windows
java -cp waves-all-<version>.jar com.wavesplatform.Exporter -c <configuration-file-name> -o <output-file-name> -h <height>
Linux
Mainnet:
sudo -u waves waves export -c /etc/waves/waves.conf -o <output-file-name> -h <height>
Testnet:
sudo -u waves-testnet waves-testnet export -c /etc/waves-testnet/waves.conf -o <output-file-name> -h <height>
macOS
java -cp waves-all-<version>.jar com.wavesplatform.Exporter -c <configuration-file-name> -o <output-file-name> -h <height>
The height
parameter allows to specify maximum height of the blocks during exporting. If the parameter is not set, all the blocks will be exported.
The output-file-name
parameter is optional ('blockchain' is used by default). The resulting export file with the <output-file-name>-<height>
name will be created in the database directory.