本文整理汇总了Golang中github.com/wchh/gocoin/lib/btc.Uint256.Bytes方法的典型用法代码示例。如果您正苦于以下问题:Golang Uint256.Bytes方法的具体用法?Golang Uint256.Bytes怎么用?Golang Uint256.Bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wchh/gocoin/lib/btc.Uint256
的用法示例。
在下文中一共展示了Uint256.Bytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NetRouteInv
// This function is called from the main thread (or from an UI)
func NetRouteInv(typ uint32, h *btc.Uint256, fromConn *OneConnection) (cnt uint) {
common.CountSafe(fmt.Sprint("NetRouteInv", typ))
// Prepare the inv
inv := new([36]byte)
binary.LittleEndian.PutUint32(inv[0:4], typ)
copy(inv[4:36], h.Bytes())
// Append it to PendingInvs in each open connection
Mutex_net.Lock()
for _, v := range OpenCons {
if v != fromConn { // except the one that this inv came from
v.Mutex.Lock()
if v.Node.DoNotRelayTxs && typ == 1 {
// This node does not want tx inv (it came with its version message)
common.CountSafe("SendInvNoTxNode")
} else {
if fromConn == nil && v.InvsRecieved == 0 {
// Do not broadcast own txs to nodes that never sent any invs to us
common.CountSafe("SendInvOwnBlocked")
} else if len(v.PendingInvs) < 500 {
v.PendingInvs = append(v.PendingInvs, inv)
cnt++
} else {
common.CountSafe("SendInvIgnored")
}
}
v.Mutex.Unlock()
}
}
Mutex_net.Unlock()
if cnt == 0 {
NetAlerts <- "WARNING: your tx has not been broadcasted to any peer"
}
return
}
示例2: SendInvToRandomPeer
func SendInvToRandomPeer(typ uint32, h *btc.Uint256) {
common.CountSafe(fmt.Sprint("NetSendOneInv", typ))
// Prepare the inv
inv := new([36]byte)
binary.LittleEndian.PutUint32(inv[0:4], typ)
copy(inv[4:36], h.Bytes())
// Append it to PendingInvs in a random connection
network.Mutex_net.Lock()
idx := rand.Intn(len(network.OpenCons))
var cnt int
for _, v := range network.OpenCons {
if idx == cnt {
v.Mutex.Lock()
v.PendingInvs = append(v.PendingInvs, inv)
v.Mutex.Unlock()
break
}
cnt++
}
network.Mutex_net.Unlock()
return
}