本文整理汇总了Golang中github.com/decred/dcrd/wire.MsgBlock.STransactions方法的典型用法代码示例。如果您正苦于以下问题:Golang MsgBlock.STransactions方法的具体用法?Golang MsgBlock.STransactions怎么用?Golang MsgBlock.STransactions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/decred/dcrd/wire.MsgBlock
的用法示例。
在下文中一共展示了MsgBlock.STransactions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewBlockDeepCopy
// NewBlockDeepCopy deep copies an entire block down to the wire components and
// returns the new block based off of this copy.
func NewBlockDeepCopy(msgBlock *wire.MsgBlock) *Block {
// Deep copy the header and all the transactions.
msgBlockCopy := new(wire.MsgBlock)
lenTxs := len(msgBlock.Transactions)
mtxsCopy := make([]*wire.MsgTx, lenTxs)
for i, mtx := range msgBlock.Transactions {
txd := NewTxDeep(mtx)
mtxsCopy[i] = txd.MsgTx()
}
msgBlockCopy.Transactions = mtxsCopy
lenStxs := len(msgBlock.STransactions)
smtxsCopy := make([]*wire.MsgTx, lenStxs)
for i, smtx := range msgBlock.STransactions {
stxd := NewTxDeep(smtx)
smtxsCopy[i] = stxd.MsgTx()
}
msgBlockCopy.STransactions = smtxsCopy
msgBlockCopy.Header = msgBlock.Header
bl := &Block{
blockHeight: int64(msgBlockCopy.Header.Height),
msgBlock: msgBlockCopy,
}
bl.hash = msgBlock.BlockHash()
return bl
}
示例2: NewBlockDeepCopyCoinbase
// NewBlockDeepCopyCoinbase returns a new instance of a block given an underlying
// wire.MsgBlock, but makes a deep copy of the coinbase transaction since it's
// sometimes mutable.
func NewBlockDeepCopyCoinbase(msgBlock *wire.MsgBlock) *Block {
// Copy the msgBlock and the pointers to all the transactions.
msgBlockCopy := new(wire.MsgBlock)
lenTxs := len(msgBlock.Transactions)
mtxsCopy := make([]*wire.MsgTx, lenTxs)
for i, mtx := range msgBlock.Transactions {
mtxsCopy[i] = mtx
}
msgBlockCopy.Transactions = mtxsCopy
lenStxs := len(msgBlock.STransactions)
smtxsCopy := make([]*wire.MsgTx, lenStxs)
for i, smtx := range msgBlock.STransactions {
smtxsCopy[i] = smtx
}
msgBlockCopy.STransactions = smtxsCopy
msgBlockCopy.Header = msgBlock.Header
// Deep copy the first transaction. Also change the coinbase pointer.
msgBlockCopy.Transactions[0] =
NewTxDeep(msgBlockCopy.Transactions[0]).MsgTx()
bl := &Block{
blockHeight: int64(msgBlockCopy.Header.Height),
msgBlock: msgBlockCopy,
}
bl.hash = msgBlock.BlockHash()
return bl
}