BlockStore
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.bitcoinj.store.BlockStore(Showing top 15 results out of 315)

origin: bitcoinj/bitcoinj

/**
 * Given a block store, looks up the previous block in this chain. Convenience method for doing
 * <tt>store.get(this.getHeader().getPrevBlockHash())</tt>.
 *
 * @return the previous block in the chain or null if it was not found in the store.
 */
public StoredBlock getPrev(BlockStore store) throws BlockStoreException {
  return store.get(getHeader().getPrevBlockHash());
}
origin: bitcoinj/bitcoinj

  /**
   * <p>Convenience method that creates a CheckpointManager, loads the given data, gets the checkpoint for the given
   * time, then inserts it into the store and sets that to be the chain head. Useful when you have just created
   * a new store from scratch and want to use configure it all in one go.</p>
   *
   * <p>Note that time is adjusted backwards by a week to account for possible clock drift in the block headers.</p>
   */
  public static void checkpoint(NetworkParameters params, InputStream checkpoints, BlockStore store, long time)
      throws IOException, BlockStoreException {
    checkNotNull(params);
    checkNotNull(store);
    checkArgument(!(store instanceof FullPrunedBlockStore), "You cannot use checkpointing with a full store.");

    time -= 86400 * 7;

    checkArgument(time > 0);
    log.info("Attempting to initialize a new block store with a checkpoint for time {} ({})", time, Utils.dateTimeFormat(time * 1000));

    BufferedInputStream stream = new BufferedInputStream(checkpoints);
    CheckpointManager manager = new CheckpointManager(params, stream);
    StoredBlock checkpoint = manager.getCheckpointBefore(time);
    store.put(checkpoint);
    store.setChainHead(checkpoint);
  }
}
origin: bitcoinj/bitcoinj

final int interval = this.getInterval();
for (int i = 0; i < interval; i++) {
  cursor = blockStore.get(hash);
  if (cursor == null) {
origin: org.bitcoinj/bitcoinj-core

@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
    throws BlockStoreException, VerificationException {
  StoredBlock newBlock = storedPrev.build(blockHeader);
  blockStore.put(newBlock);
  return newBlock;
}

origin: greenaddress/GreenBits

private static void shutdown() {
  try {
    if (peers == null) return;  // setup() never called so nothing to do.
    if (peers.isRunning())
      peers.stop();
    saveWallet(walletFile);
    store.close();
    wallet = null;
  } catch (BlockStoreException e) {
    throw new RuntimeException(e);
  }
}
origin: blockchain/thunder

public void shutdown () throws BlockStoreException {
  peerGroup.stop();
  blockStore.close();
}
origin: greenaddress/GreenBits

@Override
protected void doSetChainHead(StoredBlock chainHead) throws BlockStoreException {
  blockStore.setChainHead(chainHead);
}
origin: org.bitcoinj/bitcoinj-core

@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader)
    throws BlockStoreException, VerificationException {
  StoredBlock newBlock = storedPrev.build(blockHeader);
  blockStore.put(newBlock);
  return newBlock;
}
origin: greenaddress/GreenBits

@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
    throws BlockStoreException, VerificationException {
  StoredBlock newBlock = storedPrev.build(blockHeader);
  blockStore.put(newBlock);
  return newBlock;
}

origin: org.bitcoinj/bitcoinj-core

@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
    throws BlockStoreException, VerificationException {
  StoredBlock newBlock = storedPrev.build(blockHeader);
  blockStore.put(newBlock);
  return newBlock;
}

origin: org.bitcoinj/bitcoinj-core

/**
 * Given a block store, looks up the previous block in this chain. Convenience method for doing
 * <tt>store.get(this.getHeader().getPrevBlockHash())</tt>.
 *
 * @return the previous block in the chain or null if it was not found in the store.
 */
public StoredBlock getPrev(BlockStore store) throws BlockStoreException {
  return store.get(getHeader().getPrevBlockHash());
}
origin: org.bitcoinj/bitcoinj-core

/**
 * Given a block store, looks up the previous block in this chain. Convenience method for doing
 * <tt>store.get(this.getHeader().getPrevBlockHash())</tt>.
 *
 * @return the previous block in the chain or null if it was not found in the store.
 */
public StoredBlock getPrev(BlockStore store) throws BlockStoreException {
  return store.get(getHeader().getPrevBlockHash());
}
origin: org.bitcoinj/bitcoinj-core

@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader)
    throws BlockStoreException, VerificationException {
  StoredBlock newBlock = storedPrev.build(blockHeader);
  blockStore.put(newBlock);
  return newBlock;
}
origin: greenaddress/GreenBits

@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader)
    throws BlockStoreException, VerificationException {
  StoredBlock newBlock = storedPrev.build(blockHeader);
  blockStore.put(newBlock);
  return newBlock;
}
origin: greenaddress/GreenBits

/**
 * Given a block store, looks up the previous block in this chain. Convenience method for doing
 * <tt>store.get(this.getHeader().getPrevBlockHash())</tt>.
 *
 * @return the previous block in the chain or null if it was not found in the store.
 */
public StoredBlock getPrev(BlockStore store) throws BlockStoreException {
  return store.get(getHeader().getPrevBlockHash());
}
org.bitcoinj.storeBlockStore

Javadoc

An implementor of BlockStore saves StoredBlock objects to disk. Different implementations store them in different ways. An in-memory implementation (MemoryBlockStore) exists for unit testing but real apps will want to use implementations that save to disk.

A BlockStore is a map of hashes to StoredBlock. The hash is the double digest of the Bitcoin serialization of the block header, not the header with the extra data as well.

BlockStores are thread safe.

Most used methods

  • close
    Closes the store.
  • getChainHead
    Returns the StoredBlock that represents the top of the chain of greatest total work. Note that this
  • put
    Saves the given block header+extra data. The key isn't specified explicitly as it can be calculated
  • setChainHead
    Sets the StoredBlock that represents the top of the chain of greatest total work.
  • get
    Returns the StoredBlock given a hash. The returned values block.getHash() method will be equal to th

Popular classes and methods

  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • putExtra (Intent)
  • getApplicationContext (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • LinkedHashMap (java.util)
    Hash table implementation of the Map interface with predictable iteration order. [Sun docs] [http:/
  • Collectors (java.util.stream)
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement.A servlet is a small Java program that runs within
  • JOptionPane (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)