本文整理匯總了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())
}
}
示例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
}