本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.DBOverlay.FetchAllABlockKeys方法的典型用法代碼示例。如果您正苦於以下問題:Golang DBOverlay.FetchAllABlockKeys方法的具體用法?Golang DBOverlay.FetchAllABlockKeys怎麽用?Golang DBOverlay.FetchAllABlockKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.DBOverlay
的用法示例。
在下文中一共展示了DBOverlay.FetchAllABlockKeys方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CheckDatabaseForMissingEntries
//.........這裏部分代碼省略.........
HashMap[prevF.DatabasePrimaryIndex().String()] = "OK"
if prevF.GetPrevKeyMR().String() == "0000000000000000000000000000000000000000000000000000000000000000" {
break
}
fBlock, err := dbo.FetchFBlock(prevF.GetPrevKeyMR())
if err != nil {
panic(err)
}
if fBlock == nil {
fmt.Printf("Found a missing fblock - %v\n", prevF.GetPrevKeyMR().String())
fBlock, err := GetFBlock(prevF.GetPrevKeyMR().String())
if err != nil {
panic(err)
}
err = dbo.ProcessFBlockBatchWithoutHead(fBlock)
if err != nil {
panic(err)
}
} else {
//only iterate to the next block if it was properly fetched from the database
prevF = fBlock
}
}
fmt.Printf("\t\tIterating over ABlocks\n")
prevA, err := dbo.FetchABlockHead()
if err != nil {
panic(err)
}
for {
HashMap[prevA.DatabasePrimaryIndex().String()] = "OK"
if prevA.GetHeader().GetPrevBackRefHash().String() == "0000000000000000000000000000000000000000000000000000000000000000" {
break
}
aBlock, err := dbo.FetchABlock(prevA.GetHeader().GetPrevBackRefHash())
if err != nil {
panic(err)
}
if aBlock == nil {
fmt.Printf("Found a missing ablock - %v\n", prevA.GetHeader().GetPrevBackRefHash().String())
aBlock, err := GetABlock(prevA.GetHeader().GetPrevBackRefHash().String())
if err != nil {
panic(err)
}
err = dbo.ProcessABlockBatchWithoutHead(aBlock)
if err != nil {
panic(err)
}
} else {
//only iterate to the next block if it was properly fetched from the database
prevA = aBlock
}
}
fmt.Printf("\t\tFinding unused blocks\n")
hashes, err := dbo.FetchAllDBlockKeys()
if err != nil {
panic(err)
}
for _, h := range hashes {
if HashMap[h.String()] == "" {
fmt.Printf("Superfluous DBlock - %v\n", h)
dbo.Delete(databaseOverlay.DIRECTORYBLOCK, h.Bytes())
}
}
hashes, err = dbo.FetchAllABlockKeys()
if err != nil {
panic(err)
}
for _, h := range hashes {
if HashMap[h.String()] == "" {
fmt.Printf("Superfluous ABlock - %v\n", h)
dbo.Delete(databaseOverlay.ADMINBLOCK, h.Bytes())
}
}
hashes, err = dbo.FetchAllECBlockKeys()
if err != nil {
panic(err)
}
for _, h := range hashes {
if HashMap[h.String()] == "" {
fmt.Printf("Superfluous ECBlock - %v\n", h)
dbo.Delete(databaseOverlay.ENTRYCREDITBLOCK, h.Bytes())
}
}
hashes, err = dbo.FetchAllFBlockKeys()
if err != nil {
panic(err)
}
for _, h := range hashes {
if HashMap[h.String()] == "" {
fmt.Printf("Superfluous FBlock - %v\n", h)
dbo.Delete(databaseOverlay.FACTOIDBLOCK, h.Bytes())
}
}
}