当前位置: 首页>>代码示例>>Golang>>正文


Golang UnspentPool.Get方法代码示例

本文整理汇总了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
}
开发者ID:up4k,项目名称:skycoin,代码行数:35,代码来源:unconfirmed.go

示例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
}
开发者ID:skycoin,项目名称:skycoin,代码行数:12,代码来源:unconfirmed.go

示例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
}
开发者ID:up4k,项目名称:skycoin,代码行数:18,代码来源:unconfirmed.go


注:本文中的github.com/skycoin/skycoin/src/coin.UnspentPool.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。