/**
   * Initializes the blockchain and blockstore objects.
   *
   * @throws BlockStoreException if something went wrong and I can't create the blockchain
   */
  private void initialize() throws BlockStoreException {
    /**
     * I will define the SPV blockstore were I will save the blockchain. I will be saving the file
     * under the network type I'm being created for.
     */
    File blockChainFile = new File(BLOCKCHAIN_PATH, BLOCKCHAIN_FILENAME);

    /**
     * I will verify in the blockchain file already exists. to set a boolean variable and decide
     * later If I will add checkpoints.
     */
    boolean firstTime = true;
    if (blockChainFile.exists()) {
      firstTime = false;

      // if this is regTest I will delete the blockstore to download it again.
      if (BLOCKCHAIN_NETWORK_TYPE == BlockchainNetworkType.REG_TEST) blockChainFile.delete();
    }

    /** I create the blockstore. */
    try {
      blockStore = new SPVBlockStore(context.getParams(), blockChainFile);
    } catch (Exception e) {
      /** If there is an error saving it to file, I will save it to memory */
      initializeInMemory();
      System.out.println(
          "*** Fermat Crypto Network Warning, error creating file to store blockchain, will save it to memory.");
      System.out.println("*** Fermat Crypto Network: " + e.toString());
    }

    /** I initialize the blockchain object */
    blockChain = new BlockChain(context, wallet, blockStore);
  }
 private void initializeInMemory() throws BlockStoreException {
   blockStore = new MemoryBlockStore(context.getParams());
   blockChain = new BlockChain(context, wallet, blockStore);
 }