當前位置: 首頁>>代碼示例>>Golang>>正文


Golang DBOverlay.ProcessFBlockBatchWithoutHead方法代碼示例

本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.DBOverlay.ProcessFBlockBatchWithoutHead方法的典型用法代碼示例。如果您正苦於以下問題:Golang DBOverlay.ProcessFBlockBatchWithoutHead方法的具體用法?Golang DBOverlay.ProcessFBlockBatchWithoutHead怎麽用?Golang DBOverlay.ProcessFBlockBatchWithoutHead使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/FactomProject/factomd/common/interfaces.DBOverlay的用法示例。


在下文中一共展示了DBOverlay.ProcessFBlockBatchWithoutHead方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CheckDBlockEntries

func CheckDBlockEntries(dBlock interfaces.IDirectoryBlock, dbo interfaces.DBOverlay) {
	entries := dBlock.GetDBEntries()
	for {
		missing := 0
		for _, e := range entries {
			HashMap[e.GetKeyMR().String()] = "OK"
			switch e.GetChainID().String() {
			case "000000000000000000000000000000000000000000000000000000000000000a":
				aBlock, err := dbo.FetchABlock(e.GetKeyMR())
				if err != nil {
					panic(err)
				}
				if aBlock != nil {
					break
				}
				fmt.Printf("Found missing aBlock in #%v\n", dBlock.GetDatabaseHeight())
				missing++
				aBlock, err = GetABlock(e.GetKeyMR().String())
				if err != nil {
					panic(err)
				}
				err = dbo.ProcessABlockBatchWithoutHead(aBlock)
				if err != nil {
					panic(err)
				}
				break
			case "000000000000000000000000000000000000000000000000000000000000000f":
				fBlock, err := dbo.FetchFBlock(e.GetKeyMR())
				if err != nil {
					panic(err)
				}
				if fBlock != nil {
					break
				}
				fmt.Printf("Found missing fBlock in #%v\n", dBlock.GetDatabaseHeight())
				missing++
				fBlock, err = GetFBlock(e.GetKeyMR().String())
				if err != nil {
					panic(err)
				}
				err = dbo.ProcessFBlockBatchWithoutHead(fBlock)
				if err != nil {
					panic(err)
				}
				break
			case "000000000000000000000000000000000000000000000000000000000000000c":
				ecBlock, err := dbo.FetchECBlock(e.GetKeyMR())
				if err != nil {
					panic(err)
				}
				if ecBlock != nil {
					break
				}
				fmt.Printf("Found missing ecBlock in #%v\n", dBlock.GetDatabaseHeight())
				missing++
				ecBlock, err = GetECBlock(e.GetKeyMR().String())
				if err != nil {
					panic(err)
				}
				err = dbo.ProcessECBlockBatchWithoutHead(ecBlock, true)
				if err != nil {
					panic(err)
				}
				break
			default:
				eBlock, err := dbo.FetchEBlock(e.GetKeyMR())
				if err != nil {
					if err.Error() != "EOF" {
						panic(err)
					}
				}
				if eBlock == nil {
					fmt.Printf("Found missing eBlock in #%v\n", dBlock.GetDatabaseHeight())
					missing++
					eBlock, err = GetEBlock(e.GetKeyMR().String())
					if err != nil {
						panic(err)
					}
					err = dbo.ProcessEBlockBatchWithoutHead(eBlock, true)
					if err != nil {
						panic(err)
					}
				}

				eBlockEntries := eBlock.GetEntryHashes()
				for _, eHash := range eBlockEntries {
					if eHash.IsMinuteMarker() == true {
						continue
					}
					entry, err := dbo.FetchEntry(eHash)
					if err != nil {
						panic(err)
					}
					if entry == nil {
						fmt.Printf("Found missing entry in #%v\n", dBlock.GetDatabaseHeight())
						missing++
						entry, err := GetEntry(eHash.String())
						if err != nil {
							fmt.Printf("Problem getting entry `%v` from block %v\n", eHash.String(), e.GetKeyMR().String())
							panic(err)
//.........這裏部分代碼省略.........
開發者ID:FactomProject,項目名稱:factomd,代碼行數:101,代碼來源:porter.go

示例2: CheckDatabaseForMissingEntries

func CheckDatabaseForMissingEntries(dbo interfaces.DBOverlay) {
	fmt.Printf("\t\tIterating over DBlocks\n")

	prevD, err := dbo.FetchDBlockHead()
	if err != nil {
		panic(err)
	}

	HashMap = map[string]string{}

	for {
		CheckDBlockEntries(prevD, dbo)
		HashMap[prevD.DatabasePrimaryIndex().String()] = "OK"

		if prevD.GetHeader().GetPrevKeyMR().String() == "0000000000000000000000000000000000000000000000000000000000000000" {
			break
		}
		dBlock, err := dbo.FetchDBlock(prevD.GetHeader().GetPrevKeyMR())
		if err != nil {
			panic(err)
		}
		if dBlock == nil {
			fmt.Printf("Found a missing dblock - %v\n", prevD.GetHeader().GetPrevKeyMR().String())
			dblock, err := GetDBlock(prevD.GetHeader().GetPrevKeyMR().String())
			if err != nil {
				panic(err)
			}
			err = dbo.ProcessDBlockBatchWithoutHead(dblock)
			if err != nil {
				panic(err)
			}
		} else {
			//only iterate to the next block if it was properly fetched from the database
			prevD = dBlock
		}
	}

	fmt.Printf("\t\tIterating over ECBlocks\n")
	prevEC, err := dbo.FetchECBlockHead()
	if err != nil {
		panic(err)
	}
	for {
		HashMap[prevEC.DatabasePrimaryIndex().String()] = "OK"
		if prevEC.GetHeader().GetPrevHeaderHash().String() == "0000000000000000000000000000000000000000000000000000000000000000" {
			break
		}
		ecBlock, err := dbo.FetchECBlock(prevEC.GetHeader().GetPrevHeaderHash())
		if err != nil {
			panic(err)
		}
		if ecBlock == nil {
			fmt.Printf("Found a missing ecblock - %v\n", prevEC.GetHeader().GetPrevHeaderHash().String())
			ecblock, err := GetECBlock(prevEC.GetHeader().GetPrevHeaderHash().String())
			if err != nil {
				panic(err)
			}
			err = dbo.ProcessECBlockBatchWithoutHead(ecblock, true)
			if err != nil {
				panic(err)
			}
		} else {
			//only iterate to the next block if it was properly fetched from the database
			prevEC = ecBlock
		}
	}

	fmt.Printf("\t\tIterating over FBlocks\n")
	prevF, err := dbo.FetchFBlockHead()
	if err != nil {
		panic(err)
	}
	for {
		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 {
//.........這裏部分代碼省略.........
開發者ID:FactomProject,項目名稱:factomd,代碼行數:101,代碼來源:porter.go


注:本文中的github.com/FactomProject/factomd/common/interfaces.DBOverlay.ProcessFBlockBatchWithoutHead方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。