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

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

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

Block.unCacheTransactions介绍

暂无

代码示例

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

@Override
protected void unCache() {
  // Since we have alternate uncache methods to use internally this will only ever be called by a child
  // transaction so we only need to invalidate that part of the cache.
  unCacheTransactions();
}

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

@Override
protected void unCache() {
  // Since we have alternate uncache methods to use internally this will only ever be called by a child
  // transaction so we only need to invalidate that part of the cache.
  unCacheTransactions();
}

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

@Override
protected void unCache() {
  // Since we have alternate uncache methods to use internally this will only ever be called by a child
  // transaction so we only need to invalidate that part of the cache.
  unCacheTransactions();
}

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

@Override
protected void unCache() {
  // Since we have alternate uncache methods to use internally this will only ever be called by a child
  // transaction so we only need to invalidate that part of the cache.
  unCacheTransactions();
}

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

/** Adds a transaction to this block, with or without checking the sanity of doing so */
void addTransaction(Transaction t, boolean runSanityChecks) {
  unCacheTransactions();
  if (transactions == null) {
    transactions = new ArrayList<>();
  }
  t.setParent(this);
  if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
    throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
  else if (runSanityChecks && transactions.size() > 0 && t.isCoinBase())
    throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
  transactions.add(t);
  adjustLength(transactions.size(), t.length);
  // Force a recalculation next time the values are needed.
  merkleRoot = null;
  hash = null;
}

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

/** Adds a transaction to this block, with or without checking the sanity of doing so */
void addTransaction(Transaction t, boolean runSanityChecks) {
  unCacheTransactions();
  if (transactions == null) {
    transactions = new ArrayList<>();
  }
  t.setParent(this);
  if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
    throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
  else if (runSanityChecks && transactions.size() > 0 && t.isCoinBase())
    throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
  transactions.add(t);
  adjustLength(transactions.size(), t.length);
  // Force a recalculation next time the values are needed.
  merkleRoot = null;
  hash = null;
}

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

/** Adds a transaction to this block, with or without checking the sanity of doing so */
void addTransaction(Transaction t, boolean runSanityChecks) {
  unCacheTransactions();
  if (transactions == null) {
    transactions = new ArrayList<Transaction>();
  }
  t.setParent(this);
  if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
    throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
  else if (runSanityChecks && transactions.size() > 0 && t.isCoinBase())
    throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
  transactions.add(t);
  adjustLength(transactions.size(), t.length);
  // Force a recalculation next time the values are needed.
  merkleRoot = null;
  hash = null;
}

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

/** Adds a transaction to this block, with or without checking the sanity of doing so */
void addTransaction(Transaction t, boolean runSanityChecks) {
  unCacheTransactions();
  if (transactions == null) {
    transactions = new ArrayList<Transaction>();
  }
  t.setParent(this);
  if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
    throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
  else if (runSanityChecks && transactions.size() > 0 && t.isCoinBase())
    throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
  transactions.add(t);
  adjustLength(transactions.size(), t.length);
  // Force a recalculation next time the values are needed.
  merkleRoot = null;
  hash = null;
}

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

/** Adds a coinbase transaction to the block. This exists for unit tests.
 * 
 * @param height block height, if known, or -1 otherwise.
 */
@VisibleForTesting
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value, final int height) {
  unCacheTransactions();
  transactions = new ArrayList<>();
  Transaction coinbase = new Transaction(params);
  final ScriptBuilder inputBuilder = new ScriptBuilder();
  if (height >= Block.BLOCK_HEIGHT_GENESIS) {
    inputBuilder.number(height);
  }
  inputBuilder.data(new byte[]{(byte) txCounter, (byte) (txCounter++ >> 8)});
  // A real coinbase transaction has some stuff in the scriptSig like the extraNonce and difficulty. The
  // transactions are distinguished by every TX output going to a different key.
  //
  // Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple
  // counter in the scriptSig so every transaction has a different hash.
  coinbase.addInput(new TransactionInput(params, coinbase,
      inputBuilder.build().getProgram()));
  coinbase.addOutput(new TransactionOutput(params, coinbase, value,
      ScriptBuilder.createOutputScript(ECKey.fromPublicOnly(pubKeyTo)).getProgram()));
  transactions.add(coinbase);
  coinbase.setParent(this);
  coinbase.length = coinbase.unsafeBitcoinSerialize().length;
  adjustLength(transactions.size(), coinbase.length);
}

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

/** Adds a coinbase transaction to the block. This exists for unit tests.
 * 
 * @param height block height, if known, or -1 otherwise.
 */
@VisibleForTesting
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value, final int height) {
  unCacheTransactions();
  transactions = new ArrayList<Transaction>();
  Transaction coinbase = new Transaction(params);
  final ScriptBuilder inputBuilder = new ScriptBuilder();
  if (height >= Block.BLOCK_HEIGHT_GENESIS) {
    inputBuilder.number(height);
  }
  inputBuilder.data(new byte[]{(byte) txCounter, (byte) (txCounter++ >> 8)});
  // A real coinbase transaction has some stuff in the scriptSig like the extraNonce and difficulty. The
  // transactions are distinguished by every TX output going to a different key.
  //
  // Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple
  // counter in the scriptSig so every transaction has a different hash.
  coinbase.addInput(new TransactionInput(params, coinbase,
      inputBuilder.build().getProgram()));
  coinbase.addOutput(new TransactionOutput(params, coinbase, value,
      ScriptBuilder.createOutputScript(ECKey.fromPublicOnly(pubKeyTo)).getProgram()));
  transactions.add(coinbase);
  coinbase.setParent(this);
  coinbase.length = coinbase.unsafeBitcoinSerialize().length;
  adjustLength(transactions.size(), coinbase.length);
}

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

/** Adds a coinbase transaction to the block. This exists for unit tests.
 * 
 * @param height block height, if known, or -1 otherwise.
 */
@VisibleForTesting
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value, final int height) {
  unCacheTransactions();
  transactions = new ArrayList<>();
  Transaction coinbase = new Transaction(params);
  final ScriptBuilder inputBuilder = new ScriptBuilder();
  if (height >= Block.BLOCK_HEIGHT_GENESIS) {
    inputBuilder.number(height);
  }
  inputBuilder.data(new byte[]{(byte) txCounter, (byte) (txCounter++ >> 8)});
  // A real coinbase transaction has some stuff in the scriptSig like the extraNonce and difficulty. The
  // transactions are distinguished by every TX output going to a different key.
  //
  // Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple
  // counter in the scriptSig so every transaction has a different hash.
  coinbase.addInput(new TransactionInput(params, coinbase,
      inputBuilder.build().getProgram()));
  coinbase.addOutput(new TransactionOutput(params, coinbase, value,
      ScriptBuilder.createOutputScript(ECKey.fromPublicOnly(pubKeyTo)).getProgram()));
  transactions.add(coinbase);
  coinbase.setParent(this);
  coinbase.length = coinbase.unsafeBitcoinSerialize().length;
  adjustLength(transactions.size(), coinbase.length);
}

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

/** Adds a coinbase transaction to the block. This exists for unit tests.
 * 
 * @param height block height, if known, or -1 otherwise.
 */
@VisibleForTesting
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value, final int height) {
  unCacheTransactions();
  transactions = new ArrayList<Transaction>();
  Transaction coinbase = new Transaction(params);
  final ScriptBuilder inputBuilder = new ScriptBuilder();
  if (height >= Block.BLOCK_HEIGHT_GENESIS) {
    inputBuilder.number(height);
  }
  inputBuilder.data(new byte[]{(byte) txCounter, (byte) (txCounter++ >> 8)});
  // A real coinbase transaction has some stuff in the scriptSig like the extraNonce and difficulty. The
  // transactions are distinguished by every TX output going to a different key.
  //
  // Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple
  // counter in the scriptSig so every transaction has a different hash.
  coinbase.addInput(new TransactionInput(params, coinbase,
      inputBuilder.build().getProgram()));
  coinbase.addOutput(new TransactionOutput(params, coinbase, value,
      ScriptBuilder.createOutputScript(ECKey.fromPublicOnly(pubKeyTo)).getProgram()));
  transactions.add(coinbase);
  coinbase.setParent(this);
  coinbase.length = coinbase.unsafeBitcoinSerialize().length;
  adjustLength(transactions.size(), coinbase.length);
}

相关文章