docs: private static void setup() throws BlockStoreException {
          if (store != null) return;  // Already done.
          // Will create a fresh chain if one doesn't exist or there is an issue with this one.
          boolean reset = !chainFileName.exists();
          if (reset) {
              // No chain, so reset the wallet as we will be downloading from scratch.
              System.out.println("Chain file is missing so resetting the wallet.");
              reset();
          }
          if (mode == ValidationMode.SPV) {
              store = new SPVBlockStore(params, chainFileName);
              if (reset) {
                  try {
                      CheckpointManager.checkpoint(params, CheckpointManager.openStream(params), store,
                              wallet.getEarliestKeyCreationTime());
                      StoredBlock head = store.getChainHead();
                      System.out.println("Skipped to checkpoint " + head.getHeight() + " at "
                              + Utils.dateTimeFormat(head.getHeader().getTimeSeconds() * 1000));
                  } catch (IOException x) {
                      System.out.println("Could not load checkpoints: " + x.getMessage());
                  }
              }
              chain = new BlockChain(params, wallet, store);
          } else if (mode == ValidationMode.FULL) {
              store = new H2FullPrunedBlockStore(params, chainFileName.getAbsolutePath(), 5000);
              chain = new FullPrunedBlockChain(params, wallet, (FullPrunedBlockStore) store);
          }
          // This will ensure the wallet is saved when it changes.
          wallet.autosaveToFile(walletFile, 5, TimeUnit.SECONDS, null);
          if (peerGroup == null) {
              peerGroup = new PeerGroup(params, chain);
          }
          peerGroup.setUserAgent("WalletTool", "1.0");
          if (params == RegTestParams.get())
              peerGroup.setMinBroadcastConnections(1);
          peerGroup.addWallet(wallet);
          if (options.has("peers")) {
              String peersFlag = (String) options.valueOf("peers");
              String[] peerAddrs = peersFlag.split(",");
              for (String peer : peerAddrs) {
                  try {
                      peerGroup.addAddress(new PeerAddress(params, InetAddress.getByName(peer)));
                  } catch (UnknownHostException e) {
                      System.err.println("Could not understand peer domain name/IP address: " + peer + ": " + e.getMessage());
                      System.exit(1);
                  }
              }
          } else {
              peerGroup.setRequiredServices(0);
          }
      }