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


Golang IState.GetCurrentDirectoryBlock方法代碼示例

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


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

示例1: ProcessEndOfBlock

// End of Block means packing the current block away, and setting
// up the next
func (fs *FactoidState) ProcessEndOfBlock(state interfaces.IState) {
	var hash, hash2 interfaces.IHash

	if fs.GetCurrentBlock() == nil {
		panic("Invalid state on initialization")
	}

	hash = fs.CurrentBlock.GetHash()
	hash2 = fs.CurrentBlock.GetLedgerKeyMR()

	state.GetCurrentDirectoryBlock().GetDBEntries()[2].SetKeyMR(hash)

	if err := state.GetDB().SaveFactoidBlockHead(fs.CurrentBlock); err != nil {
		panic(err)
	}

	state.SetPrevFactoidKeyMR(hash)

	fs.CurrentBlock = block.NewFBlock(fs.GetFactoshisPerEC(), state.GetDBHeight()+1)

	t := coinbase.GetCoinbase(primitives.GetTimeMilli())
	err := fs.CurrentBlock.AddCoinbase(t)
	if err != nil {
		panic(err.Error())
	}
	fs.UpdateTransaction(t)

	if hash != nil {
		fs.CurrentBlock.SetPrevKeyMR(hash.Bytes())
		fs.CurrentBlock.SetPrevLedgerKeyMR(hash2.Bytes())
	}

}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:35,代碼來源:factoidstate.go

示例2: LatestDirBlockLocator

// LatestDirBlockLocator returns a block locator for the latest known tip of the
// main (best) chain.
func LatestDirBlockLocator(state interfaces.IState) (BlockLocator, error) {
	latestDirBlockHash := state.GetCurrentDirectoryBlock().GetHash() //, _, _ := db.FetchBlockHeightCache()

	if latestDirBlockHash == nil {
		latestDirBlockHash = NewZeroHash() //zeroHash
	}

	// The best chain is set, so use its hash.
	return DirBlockLocatorFromHash(latestDirBlockHash, state), nil
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:12,代碼來源:blocklocator.go


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