BlockImporter: support signet and regtest too

* Update usage for `args[1]` to "(mainnet|testnet|signet|regtest)"
* Use `BitcoinNetwork.fromString()` to parse `args[1]`
This commit is contained in:
Sean Gilligan 2023-08-12 13:05:59 -07:00 committed by Andreas Schildbach
parent b792354f55
commit 49f7ddbc0f

View File

@ -29,16 +29,13 @@ import static org.bitcoinj.base.internal.Preconditions.checkArgument;
/** Very thin wrapper around {@link BlockFileLoader} */
public class BlockImporter {
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException {
System.out.println("USAGE: BlockImporter (prod|test) (MemFull|Mem|SPV) [blockStore]");
System.out.println("USAGE: BlockImporter (mainnet|testnet|signet|regtest) (MemFull|Mem|SPV) [blockStore]");
System.out.println(" blockStore is required unless type is Mem or MemFull");
System.out.println(" Does full verification if the store supports it");
checkArgument(args.length == 2 || args.length == 3);
Network network;
if (args[0].equals("test"))
network = BitcoinNetwork.TESTNET;
else
network = BitcoinNetwork.MAINNET;
Network network = BitcoinNetwork.fromString(args[1])
.orElseThrow(() -> new IllegalArgumentException("Unknown network: " + args[1]));
NetworkParameters params = NetworkParameters.of(network);
BlockStore store;