本文整理汇总了Golang中github.com/skycoin/skycoin/src/coin.UnspentPool.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang UnspentPool.Get方法的具体用法?Golang UnspentPool.Get怎么用?Golang UnspentPool.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skycoin/skycoin/src/coin.UnspentPool
的用法示例。
在下文中一共展示了UnspentPool.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createUnconfirmedTxn
// Creates an unconfirmed transaction
func (self *UnconfirmedTxnPool) createUnconfirmedTxn(bcUnsp *coin.UnspentPool,
t coin.Transaction, addrs map[coin.Address]byte) UnconfirmedTxn {
now := util.Now()
ut := UnconfirmedTxn{
Txn: t,
Received: now,
Checked: now,
Announced: util.ZeroTime(),
IsOurReceive: false,
IsOurSpend: false,
}
// Check if this unspent is related to us
if addrs != nil {
// Check if this is one of our receiving txns
for i, _ := range t.Out {
if _, ok := addrs[t.Out[i].Address]; ok {
ut.IsOurReceive = true
break
}
}
// Check if this is one of our spending txns
for i, _ := range t.In {
if ux, ok := bcUnsp.Get(t.In[i]); ok {
if _, ok := addrs[ux.Body.Address]; ok {
ut.IsOurSpend = true
break
}
}
}
}
return ut
}
示例2: AllSpendsOutputs
// AllSpendsOutputs returns all spending outputs in unconfirmed tx pool.
func (utp *UnconfirmedTxnPool) AllSpendsOutputs(bcUnspent *coin.UnspentPool) []ReadableOutput {
outs := []ReadableOutput{}
for _, tx := range utp.Txns {
for _, in := range tx.Txn.In {
if ux, ok := bcUnspent.Get(in); ok {
outs = append(outs, NewReadableOutput(ux))
}
}
}
return outs
}
示例3: SpendsForAddresses
// Returns all unconfirmed coin.UxOut spends for addresses
// Looks at all inputs for unconfirmed txns, gets their source UxOut from the
// blockchain's unspent pool, and returns as coin.AddressUxOuts
// TODO -- optimize or cache
func (self *UnconfirmedTxnPool) SpendsForAddresses(bcUnspent *coin.UnspentPool,
a map[coin.Address]byte) coin.AddressUxOuts {
auxs := make(coin.AddressUxOuts, len(a))
for _, utx := range self.Txns {
for _, h := range utx.Txn.In {
if ux, ok := bcUnspent.Get(h); ok {
if _, ok := a[ux.Body.Address]; ok {
auxs[ux.Body.Address] = append(auxs[ux.Body.Address], ux)
}
}
}
}
return auxs
}