本文整理匯總了Golang中github.com/FactomProject/FactomCode/common.DirBlockInfo.BTCBlockHeight方法的典型用法代碼示例。如果您正苦於以下問題:Golang DirBlockInfo.BTCBlockHeight方法的具體用法?Golang DirBlockInfo.BTCBlockHeight怎麽用?Golang DirBlockInfo.BTCBlockHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/FactomCode/common.DirBlockInfo
的用法示例。
在下文中一共展示了DirBlockInfo.BTCBlockHeight方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: anchorChainToDirBlockInfo
func anchorChainToDirBlockInfo(aRecord *anchor.AnchorRecord) (*common.DirBlockInfo, error) {
dirBlockInfo := new(common.DirBlockInfo)
dirBlockInfo.DBHeight = aRecord.DBHeight
dirBlockInfo.BTCTxOffset = aRecord.Bitcoin.Offset
dirBlockInfo.BTCBlockHeight = aRecord.Bitcoin.BlockHeight
mrBytes, _ := hex.DecodeString(aRecord.KeyMR)
dirBlockInfo.DBMerkleRoot, _ = common.NewShaHash(mrBytes)
dirBlockInfo.BTCConfirmed = true
txSha, _ := wire.NewShaHashFromStr(aRecord.Bitcoin.TXID)
dirBlockInfo.BTCTxHash = toHash(txSha)
blkSha, _ := wire.NewShaHashFromStr(aRecord.Bitcoin.BlockHash)
dirBlockInfo.BTCBlockHash = toHash(blkSha)
dblock, err := db.FetchDBlockByHeight(aRecord.DBHeight)
if err != nil {
fmt.Printf("err in FetchDBlockByHeight: %d\n", aRecord.DBHeight)
dirBlockInfo.DBHash = new(common.Hash)
} else {
dirBlockInfo.Timestamp = int64(dblock.Header.Timestamp * 60)
dirBlockInfo.DBHash = dblock.DBHash
}
fmt.Printf("dirBlockInfo: %s\n", spew.Sdump(dirBlockInfo))
return dirBlockInfo, nil
}