本文整理匯總了Golang中github.com/tendermint/tendermint/types.PartSet.IsComplete方法的典型用法代碼示例。如果您正苦於以下問題:Golang PartSet.IsComplete方法的具體用法?Golang PartSet.IsComplete怎麽用?Golang PartSet.IsComplete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tendermint/tendermint/types.PartSet
的用法示例。
在下文中一共展示了PartSet.IsComplete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SaveBlock
// blockParts: Must be parts of the block
// seenValidation: The +2/3 precommits that were seen which committed at height.
// If all the nodes restart after committing a block,
// we need this to reload the precommits to catch-up nodes to the
// most recent height. Otherwise they'd stall at H-1.
func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenValidation *types.Validation) {
height := block.Height
if height != bs.height+1 {
PanicSanity(Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.height+1, height))
}
if !blockParts.IsComplete() {
PanicSanity(Fmt("BlockStore can only save complete block part sets"))
}
// Save block meta
meta := types.NewBlockMeta(block, blockParts)
metaBytes := wire.BinaryBytes(meta)
bs.db.Set(calcBlockMetaKey(height), metaBytes)
// Save block parts
for i := 0; i < blockParts.Total(); i++ {
bs.saveBlockPart(height, i, blockParts.GetPart(i))
}
// Save block validation (duplicate and separate from the Block)
blockValidationBytes := wire.BinaryBytes(block.LastValidation)
bs.db.Set(calcBlockValidationKey(height-1), blockValidationBytes)
// Save seen validation (seen +2/3 precommits for block)
seenValidationBytes := wire.BinaryBytes(seenValidation)
bs.db.Set(calcSeenValidationKey(height), seenValidationBytes)
// Save new BlockStoreStateJSON descriptor
BlockStoreStateJSON{Height: height}.Save(bs.db)
// Done!
bs.height = height
}