本文整理汇总了Golang中github.com/skycoin/skycoin/src/coin.Block.GetTransaction方法的典型用法代码示例。如果您正苦于以下问题:Golang Block.GetTransaction方法的具体用法?Golang Block.GetTransaction怎么用?Golang Block.GetTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skycoin/skycoin/src/coin.Block
的用法示例。
在下文中一共展示了Block.GetTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAddressTransactions
// GetAddressTransactions returns the Transactions whose unspents give coins to a cipher.Address.
// This includes unconfirmed txns' predicted unspents.
func (vs *Visor) GetAddressTransactions(a cipher.Address) []Transaction {
var txns []Transaction
// Look in the blockchain
uxs := vs.Blockchain.GetUnspent().AllForAddress(a)
mxSeq := vs.HeadBkSeq()
var bk *coin.Block
for _, ux := range uxs {
if bk = vs.GetBlockBySeq(ux.Head.BkSeq); bk == nil {
return txns
}
tx, ok := bk.GetTransaction(ux.Body.SrcTransaction)
if ok {
h := mxSeq - bk.Head.BkSeq + 1
txns = append(txns, Transaction{
Txn: tx,
Status: NewConfirmedTransactionStatus(h),
Time: bk.Time(),
})
}
}
// Look in the unconfirmed pool
uxs = vs.Unconfirmed.Unspent.AllForAddress(a)
for _, ux := range uxs {
tx, ok := vs.Unconfirmed.Txns[ux.Body.SrcTransaction]
if !ok {
logger.Critical("Unconfirmed unspent missing unconfirmed txn")
continue
}
txns = append(txns, Transaction{
Txn: tx.Txn,
Status: NewUnconfirmedTransactionStatus(),
Time: uint64(tx.Received.Unix()),
})
}
return txns
}