本文整理匯總了Golang中github.com/FactomProject/btcd/wire.ShaHash.Bytes方法的典型用法代碼示例。如果您正苦於以下問題:Golang ShaHash.Bytes方法的具體用法?Golang ShaHash.Bytes怎麽用?Golang ShaHash.Bytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/btcd/wire.ShaHash
的用法示例。
在下文中一共展示了ShaHash.Bytes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: shaBlkToKey
func shaBlkToKey(sha *wire.ShaHash) []byte {
shaB := sha.Bytes()
return shaB
}
示例2: shaSpentTxToKey
func shaSpentTxToKey(sha *wire.ShaHash) []byte {
shaB := sha.Bytes()
shaB = append(shaB, "sx"...)
return shaB
}
示例3: pushDirBlockMsg
// pushDirBlockMsg sends a dir block message for the provided block hash to the
// connected peer. An error is returned if the block hash is not known.
func (p *peer) pushDirBlockMsg(sha *wire.ShaHash, doneChan, waitChan chan struct{}) error {
commonhash := new(common.Hash)
commonhash.SetBytes(sha.Bytes())
blk, err := db.FetchDBlockByHash(commonhash)
if err != nil {
peerLog.Tracef("Unable to fetch requested dir block sha %v: %v",
sha, err)
if doneChan != nil {
doneChan <- struct{}{}
}
return err
}
// Once we have fetched data wait for any previous operation to finish.
if waitChan != nil {
<-waitChan
}
// We only send the channel for this message if we aren't sending(sha)
// an inv straight after.
var dc chan struct{}
sendInv := p.continueHash != nil && p.continueHash.IsEqual(sha)
if !sendInv {
dc = doneChan
}
msg := wire.NewMsgDirBlock()
msg.DBlk = blk
p.QueueMessage(msg, dc) //blk.MsgBlock(), dc)
// When the peer requests the final block that was advertised in
// response to a getblocks message which requested more blocks than
// would fit into a single message, send it a new inventory message
// to trigger it to issue another getblocks message for the next
// batch of inventory.
if p.continueHash != nil && p.continueHash.IsEqual(sha) {
peerLog.Debug("continueHash: " + spew.Sdump(sha))
// Sleep for 5 seconds for the peer to catch up
time.Sleep(5 * time.Second)
//
// Note: Rather than the latest block height, we should pass
// the last block height of this batch of wire.MaxBlockLocatorsPerMsg
// to signal this is the end of the batch and
// to trigger a client to send a new GetDirBlocks message
//
//hash, _, err := db.FetchBlockHeightCache()
//if err == nil {
invMsg := wire.NewMsgDirInvSizeHint(1)
iv := wire.NewInvVect(wire.InvTypeFactomDirBlock, sha) //hash)
invMsg.AddInvVect(iv)
p.QueueMessage(invMsg, doneChan)
p.continueHash = nil
//} else if doneChan != nil {
if doneChan != nil {
doneChan <- struct{}{}
}
}
return nil
}