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

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

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

Block.getOptimalEncodingMessageSize介绍

暂无

代码示例

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

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > MAX_BLOCK_SIZE)
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  if (flags.contains(VerifyFlag.SEGWIT)) checkSegwitCommit();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

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

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > MAX_BLOCK_SIZE)
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

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

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > MAX_BLOCK_SIZE)
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

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

/**
 * Checks the block contents
 *
 * @param height block height, if known, or -1 otherwise. If valid, used
 * to validate the coinbase input script of v2 and above blocks.
 * @param flags flags to indicate which tests should be applied (i.e.
 * whether to test for height in the coinbase transaction).
 * @throws VerificationException if there was an error verifying the block.
 */
public void verifyTransactions(final int height, final EnumSet<VerifyFlag> flags) throws VerificationException {
  // Now we need to check that the body of the block actually matches the headers. The network won't generate
  // an invalid block, but if we didn't validate this then an untrusted man-in-the-middle could obtain the next
  // valid block from the network and simply replace the transactions in it with their own fictional
  // transactions that reference spent or non-existant inputs.
  if (transactions.isEmpty())
    throw new VerificationException("Block had no transactions");
  if (this.getOptimalEncodingMessageSize() > (height >= params.getDIP0001BlockHeight() ? MAX_BLOCK_SIZE_DIP0001 : MAX_BLOCK_SIZE))
    throw new VerificationException("Block larger than MAX_BLOCK_SIZE");
  checkTransactions(height, flags);
  checkMerkleRoot();
  checkSigOps();
  for (Transaction transaction : transactions)
    transaction.verify();
  }

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

checkState(stream.size() == b64.getMessageSize());
checkState(Arrays.equals(stream.toByteArray(), b64.bitcoinSerialize()));
checkState(b64.getOptimalEncodingMessageSize() == b64Original.block.getMessageSize());

相关文章

微信公众号

最新文章

更多