Android Open Source - bitfynd-wallet-android Blockchain State

From Project

Back to project page bitfynd-wallet-android.


The source code is released under:

GNU General Public License

If you think the Android project bitfynd-wallet-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

 * Copyright 2014 the original author or authors.
 *//ww  w.j  a  va2  s  .c om
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <>.

package de.schildbach.wallet.service;

import java.util.Date;
import java.util.EnumSet;
import java.util.Set;

import android.content.Intent;

 * @author Andreas Schildbach
public class BlockchainState
  private static final String EXTRA_BEST_CHAIN_DATE = "best_chain_date";
  private static final String EXTRA_BEST_CHAIN_HEIGHT = "best_chain_height";
  private static final String EXTRA_REPLAYING = "replaying";
  private static final String EXTRA_IMPEDIMENTS = "impediment";

  public enum Impediment

  public final Date bestChainDate;
  public final int bestChainHeight;
  public final boolean replaying;
  public final EnumSet<Impediment> impediments;

  public BlockchainState(final Date bestChainDate, final int bestChainHeight, final boolean replaying, final Set<Impediment> impediments)
    this.bestChainDate = bestChainDate;
    this.bestChainHeight = bestChainHeight;
    this.replaying = replaying;
    this.impediments = EnumSet.copyOf(impediments);

  public static BlockchainState fromIntent(final Intent intent)
    final Date bestChainDate = (Date) intent.getSerializableExtra(EXTRA_BEST_CHAIN_DATE);
    final int bestChainHeight = intent.getIntExtra(EXTRA_BEST_CHAIN_HEIGHT, -1);
    final boolean replaying = intent.getBooleanExtra(EXTRA_REPLAYING, false);
    final Set<Impediment> impediments = (Set<Impediment>) intent.getSerializableExtra(EXTRA_IMPEDIMENTS);

    return new BlockchainState(bestChainDate, bestChainHeight, replaying, impediments);

  public void putExtras(final Intent intent)
    intent.putExtra(EXTRA_BEST_CHAIN_DATE, bestChainDate);
    intent.putExtra(EXTRA_BEST_CHAIN_HEIGHT, bestChainHeight);
    intent.putExtra(EXTRA_REPLAYING, replaying);
    intent.putExtra(EXTRA_IMPEDIMENTS, impediments);

Java Source Code List