Skip to content

Database and Block Operations

MiaoShi09 edited this page Jan 24, 2019 · 1 revision

AionR provides CLI command to operate database and blocks. This wiki page shows you how to use these commands.

Block Import and Export

Export

AionR allows the user to export a continuous number of blocks to a file which can be imported into another AionR. export command allows up 3 options:

./aion export [--format=hex|binary] [--to=[end block number]] [--from=[start block number]] [export file path]

Default value:

  • --format: binary;
  • --to: latest
  • --from: 1

Import

AionR allows the user to import the exported block file back. import command has 1 option:

./aion import [--format=hex|binary|auto] [file to import]

The import file format can be automatically detected.

Reverting to Previous Blocks

AionR Kernel allows users to revert database to a certain block number. This functionality is meant for removing from the database all blocks greater than the one given as parameter. The revert feature makes permanent changes to the database. If you are unsure about using it, back-up the database first.

$ ./aion [--chain=<config/path/of/chain>.toml] revert --to=10
> Loading config file from <config/path/of/chain>.toml
> 2019-01-02 18:19:38 Configured for <network_name> using POWEquihashEngine engine
> 2019-01-02 18:19:39 Attempting to revert best block from 24 to 10 ...
> 2019-01-02 18:19:39 Revert BlockChain to #10 completed in 310 ms

Or with quick launch script:

$ ./mainnet.sh revert --to=10
> 2019-01-23 10:40:01 Configured for Mainnet using POWEquihashEngine engine
> 2019-01-23 10:40:02 Attempting to revert best block from 20077 to 10 ...
> 2019-01-23 10:40:02 #20000
> 2019-01-23 10:40:02 #19000
> 2019-01-23 10:40:02 #18000
> 2019-01-23 10:40:02 #17000
> 2019-01-23 10:40:02 #16000
> 2019-01-23 10:40:02 #15000
> 2019-01-23 10:40:02 #14000
> 2019-01-23 10:40:02 #13000
> 2019-01-23 10:40:02 #12000
> 2019-01-23 10:40:02 #11000
> 2019-01-23 10:40:02 #10000
> 2019-01-23 10:40:02 #9000
> 2019-01-23 10:40:02 #8000
> 2019-01-23 10:40:02 #7000
> 2019-01-23 10:40:02 #6000
> 2019-01-23 10:40:02 #5000
> 2019-01-23 10:40:02 #4000
> 2019-01-23 10:40:02 #3000
> 2019-01-23 10:40:02 #2000
> 2019-01-23 10:40:02 #1000
> 2019-01-23 10:40:02 Revert BlockChain to #10 completed in 1255 ms

CAUTION: Pressing ctrl+c during the reverting process will damage the database and the database cannot be recovered. Please backup the database before reverting.

Kill Database

AionR provides db kill command to clean the database based on the current configuration and the genesis file. Usage:

./aion [options] db kill
# e.g. clean custom network DB
./custom.sh db kill
> 2019-01-24 18:36:18 Database "/home/xxx/.aion/chains/custom/db/94e2b7a17246caf6/archive" deleted.
Clone this wiki locally