本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.DBOverlay.FetchDirBlockInfoByKeyMR方法的典型用法代碼示例。如果您正苦於以下問題:Golang DBOverlay.FetchDirBlockInfoByKeyMR方法的具體用法?Golang DBOverlay.FetchDirBlockInfoByKeyMR怎麽用?Golang DBOverlay.FetchDirBlockInfoByKeyMR使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.DBOverlay
的用法示例。
在下文中一共展示了DBOverlay.FetchDirBlockInfoByKeyMR方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateReceipt
func CreateReceipt(dbo interfaces.DBOverlay, entryID interfaces.IHash) (*Receipt, error) {
receipt := new(Receipt)
receipt.Entry = new(JSON)
receipt.Entry.Key = entryID.String()
//EBlock
hash, err := dbo.FetchIncludedIn(entryID)
if err != nil {
return nil, err
}
if hash == nil {
return nil, fmt.Errorf("Block containing entry not found")
}
eBlock, err := dbo.FetchEBlock(hash)
if err != nil {
return nil, err
}
if eBlock == nil {
return nil, fmt.Errorf("EBlock not found")
}
hash = eBlock.DatabasePrimaryIndex()
receipt.EntryBlockKeyMR = hash.(*primitives.Hash)
entries := eBlock.GetEntryHashes()
//fmt.Printf("eBlock entries - %v\n\n", entries)
branch := primitives.BuildMerkleBranchForEntryHash(entries, entryID, true)
blockNode := new(primitives.MerkleNode)
left, err := eBlock.HeaderHash()
if err != nil {
return nil, err
}
blockNode.Left = left.(*primitives.Hash)
blockNode.Right = eBlock.BodyKeyMR().(*primitives.Hash)
blockNode.Top = hash.(*primitives.Hash)
//fmt.Printf("eBlock blockNode - %v\n\n", blockNode)
branch = append(branch, blockNode)
receipt.MerkleBranch = append(receipt.MerkleBranch, branch...)
//str, _ := eBlock.JSONString()
//fmt.Printf("eBlock - %v\n\n", str)
//DBlock
hash, err = dbo.FetchIncludedIn(hash)
if err != nil {
return nil, err
}
if hash == nil {
return nil, fmt.Errorf("Block containing EBlock not found")
}
dBlock, err := dbo.FetchDBlock(hash)
if err != nil {
return nil, err
}
if dBlock == nil {
return nil, fmt.Errorf("DBlock not found")
}
//str, _ = dBlock.JSONString()
//fmt.Printf("dBlock - %v\n\n", str)
entries = dBlock.GetEntryHashesForBranch()
//fmt.Printf("dBlock entries - %v\n\n", entries)
//merkleTree := primitives.BuildMerkleTreeStore(entries)
//fmt.Printf("dBlock merkleTree - %v\n\n", merkleTree)
branch = primitives.BuildMerkleBranchForEntryHash(entries, receipt.EntryBlockKeyMR, true)
blockNode = new(primitives.MerkleNode)
left, err = dBlock.HeaderHash()
if err != nil {
return nil, err
}
blockNode.Left = left.(*primitives.Hash)
blockNode.Right = dBlock.BodyKeyMR().(*primitives.Hash)
blockNode.Top = hash.(*primitives.Hash)
//fmt.Printf("dBlock blockNode - %v\n\n", blockNode)
branch = append(branch, blockNode)
receipt.MerkleBranch = append(receipt.MerkleBranch, branch...)
//DirBlockInfo
hash = dBlock.DatabasePrimaryIndex()
receipt.DirectoryBlockKeyMR = hash.(*primitives.Hash)
dirBlockInfo, err := dbo.FetchDirBlockInfoByKeyMR(hash)
if err != nil {
return nil, err
}
if dirBlockInfo != nil {
dbi := dirBlockInfo.(*dbInfo.DirBlockInfo)
//.........這裏部分代碼省略.........