本文整理汇总了Golang中github.com/conformal/btcwire.MsgBlock.Header方法的典型用法代码示例。如果您正苦于以下问题:Golang MsgBlock.Header方法的具体用法?Golang MsgBlock.Header怎么用?Golang MsgBlock.Header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/conformal/btcwire.MsgBlock
的用法示例。
在下文中一共展示了MsgBlock.Header方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewBlockTemplate
//.........这里部分代码省略.........
// Calculate the final transaction priority using the input
// value age sum as well as the adjusted transaction size. The
// formula is: sum(inputValue * inputAge) / adjustedTxSize
txSize := tx.MsgTx().SerializeSize()
prioItem.priority = calcPriority(tx, txSize, inputValueAge)
// Calculate the fee in Satoshi/KB.
// NOTE: This is a more precise value than the one calculated
// during calcMinRelayFee which rounds up to the nearest full
// kilobyte boundary. This is beneficial since it provides an
// incentive to create smaller transactions.
prioItem.feePerKB = float64(txDesc.Fee) / (float64(txSize) / 1000)
prioItem.fee = txDesc.Fee
// Add the transaction to the priority queue to mark it ready
// for inclusion in the block unless it has dependencies.
if prioItem.dependsOn == nil {
heap.Push(priorityQueue, prioItem)
}
// Merge the store which contains all of the input transactions
// for this transaction into the input transaction store. This
// allows the code below to avoid a second lookup.
mergeTxStore(blockTxStore, txStore)
}
minrLog.Tracef("Priority queue len %d, dependers len %d",
priorityQueue.Len(), len(dependers))
// The starting block size is the size of the block header plus the max
// possible transaction count size, plus the size of the coinbase
// transaction.
blockSize := blockHeaderOverhead + uint32(coinbaseTx.MsgTx().SerializeSize())
blockSigOps := numCoinbaseSigOps
totalFees := int64(0)
// Choose which transactions make it into the block.
for priorityQueue.Len() > 0 {
// Grab the highest priority (or highest fee per kilobyte
// depending on the sort order) transaction.
prioItem := heap.Pop(priorityQueue).(*txPrioItem)
tx := prioItem.tx
// Grab the list of transactions which depend on this one (if
// any) and remove the entry for this transaction as it will
// either be included or skipped, but in either case the deps
// are no longer needed.
deps := dependers[*tx.Sha()]
delete(dependers, *tx.Sha())
// Enforce maximum block size. Also check for overflow.
txSize := uint32(tx.MsgTx().SerializeSize())
blockPlusTxSize := blockSize + txSize
if blockPlusTxSize < blockSize || blockPlusTxSize >= cfg.BlockMaxSize {
minrLog.Tracef("Skipping tx %s because it would exceed "+
"the max block size", tx.Sha())
logSkippedDeps(tx, deps)
continue
}
// Enforce maximum signature operations per block. Also check
// for overflow.
numSigOps := int64(btcchain.CountSigOps(tx))
if blockSigOps+numSigOps < blockSigOps ||
blockSigOps+numSigOps > btcchain.MaxSigOpsPerBlock {