org.bitcoinj.core.BlockChain.setChainHead()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.bitcoinj.core.BlockChain.setChainHead()方法的一些代码示例,展示了BlockChain.setChainHead()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockChain.setChainHead()方法的具体详情如下:
包路径:org.bitcoinj.core.BlockChain
类名称:BlockChain
方法名:setChainHead

BlockChain.setChainHead介绍

暂无

代码示例

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

@Override
protected void rollbackBlockStore(int height) throws BlockStoreException {
  lock.lock();
  try {
    int currentHeight = getBestChainHeight();
    checkArgument(height >= 0 && height <= currentHeight, "Bad height: %s", height);
    if (height == currentHeight)
      return; // nothing to do
    // Look for the block we want to be the new chain head
    StoredBlock newChainHead = blockStore.getChainHead();
    while (newChainHead.getHeight() > height) {
      newChainHead = newChainHead.getPrev(blockStore);
      if (newChainHead == null)
        throw new BlockStoreException("Unreachable height");
    }
    // Modify store directly
    blockStore.put(newChainHead);
    this.setChainHead(newChainHead);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: fr.acinq/bitcoinj-core

@Override
protected void rollbackBlockStore(int height) throws BlockStoreException {
  lock.lock();
  try {
    int currentHeight = getBestChainHeight();
    checkArgument(height >= 0 && height <= currentHeight, "Bad height: %s", height);
    if (height == currentHeight)
      return; // nothing to do
    // Look for the block we want to be the new chain head
    StoredBlock newChainHead = blockStore.getChainHead();
    while (newChainHead.getHeight() > height) {
      newChainHead = newChainHead.getPrev(blockStore);
      if (newChainHead == null)
        throw new BlockStoreException("Unreachable height");
    }
    // Modify store directly
    blockStore.put(newChainHead);
    this.setChainHead(newChainHead);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: greenaddress/GreenBits

@Override
protected void rollbackBlockStore(int height) throws BlockStoreException {
  lock.lock();
  try {
    int currentHeight = getBestChainHeight();
    checkArgument(height >= 0 && height <= currentHeight, "Bad height: %s", height);
    if (height == currentHeight)
      return; // nothing to do
    // Look for the block we want to be the new chain head
    StoredBlock newChainHead = blockStore.getChainHead();
    while (newChainHead.getHeight() > height) {
      newChainHead = newChainHead.getPrev(blockStore);
      if (newChainHead == null)
        throw new BlockStoreException("Unreachable height");
    }
    // Modify store directly
    blockStore.put(newChainHead);
    this.setChainHead(newChainHead);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: HashEngineering/dashj

@Override
protected void rollbackBlockStore(int height) throws BlockStoreException {
  lock.lock();
  try {
    int currentHeight = getBestChainHeight();
    checkArgument(height >= 0 && height <= currentHeight, "Bad height: %s", height);
    if (height == currentHeight)
      return; // nothing to do
    // Look for the block we want to be the new chain head
    StoredBlock newChainHead = blockStore.getChainHead();
    while (newChainHead.getHeight() > height) {
      newChainHead = newChainHead.getPrev(blockStore);
      if (newChainHead == null)
        throw new BlockStoreException("Unreachable height");
    }
    // Modify store directly
    blockStore.put(newChainHead);
    this.setChainHead(newChainHead);
  } finally {
    lock.unlock();
  }
}

相关文章