本文整理匯總了Golang中github.com/FactomProject/FactomCode/common.EChain.NextBlockHeight方法的典型用法代碼示例。如果您正苦於以下問題:Golang EChain.NextBlockHeight方法的具體用法?Golang EChain.NextBlockHeight怎麽用?Golang EChain.NextBlockHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/FactomCode/common.EChain
的用法示例。
在下文中一共展示了EChain.NextBlockHeight方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: initEChainFromDB
// Initialize the entry chains in memory from db
func initEChainFromDB(chain *common.EChain) {
eBlocks, _ := db.FetchAllEBlocksByChain(chain.ChainID)
sort.Sort(util.ByEBlockIDAccending(*eBlocks))
for i := 0; i < len(*eBlocks); i = i + 1 {
if uint32(i) != (*eBlocks)[i].Header.EBSequence {
panic(errors.New("BlockID does not equal index for chain:" + chain.ChainID.String() + " block:" + fmt.Sprintf("%v", (*eBlocks)[i].Header.EBSequence)))
}
}
var err error
if len(*eBlocks) == 0 {
chain.NextBlockHeight = 0
chain.NextBlock, err = common.MakeEBlock(chain, nil)
if err != nil {
panic(err)
}
} else {
chain.NextBlockHeight = uint32(len(*eBlocks))
chain.NextBlock, err = common.MakeEBlock(chain, &(*eBlocks)[len(*eBlocks)-1])
if err != nil {
panic(err)
}
}
// Initialize chain with the first entry (Name and rules) for non-server mode
if nodeMode != common.SERVER_NODE && chain.FirstEntry == nil && len(*eBlocks) > 0 {
chain.FirstEntry, _ = db.FetchEntryByHash((*eBlocks)[0].Body.EBEntries[0])
if chain.FirstEntry != nil {
db.InsertChain(chain)
}
}
}