本文整理匯總了Golang中github.com/FactomProject/factomd/common/directoryBlock.DirectoryBlock類的典型用法代碼示例。如果您正苦於以下問題:Golang DirectoryBlock類的具體用法?Golang DirectoryBlock怎麽用?Golang DirectoryBlock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DirectoryBlock類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateTestDirectoryBlockHeader
func CreateTestDirectoryBlockHeader(prevBlock *directoryBlock.DirectoryBlock) *directoryBlock.DBlockHeader {
header := new(directoryBlock.DBlockHeader)
header.SetBodyMR(primitives.Sha(primitives.NewZeroHash().Bytes()))
header.SetBlockCount(0)
header.SetNetworkID(0xffff)
if prevBlock == nil {
header.SetDBHeight(0)
header.SetPrevLedgerKeyMR(primitives.NewZeroHash())
header.SetPrevKeyMR(primitives.NewZeroHash())
header.SetTimestamp(1234)
} else {
header.SetDBHeight(prevBlock.Header.GetDBHeight() + 1)
header.SetPrevLedgerKeyMR(prevBlock.GetHash())
keyMR, err := prevBlock.BuildKeyMerkleRoot()
if err != nil {
panic(err)
}
header.SetPrevKeyMR(keyMR)
header.SetTimestamp(prevBlock.Header.GetTimestamp() + 1)
}
header.SetVersion(1)
return header
}
示例2: CreateTestDirectoryBlockHeader
func CreateTestDirectoryBlockHeader(prevBlock *directoryBlock.DirectoryBlock) *directoryBlock.DBlockHeader {
header := new(directoryBlock.DBlockHeader)
header.SetBodyMR(primitives.Sha(primitives.NewZeroHash().Bytes()))
header.SetBlockCount(0)
header.SetNetworkID(constants.MAIN_NETWORK_ID)
if prevBlock == nil {
header.SetDBHeight(0)
header.SetPrevFullHash(primitives.NewZeroHash())
header.SetPrevKeyMR(primitives.NewZeroHash())
header.SetTimestamp(primitives.NewTimestampFromMinutes(1234))
} else {
header.SetDBHeight(prevBlock.Header.GetDBHeight() + 1)
header.SetPrevFullHash(prevBlock.GetHash())
keyMR, err := prevBlock.BuildKeyMerkleRoot()
if err != nil {
panic(err)
}
header.SetPrevKeyMR(keyMR)
header.SetTimestamp(primitives.NewTimestampFromMinutes(prevBlock.Header.GetTimestamp().GetTimeMinutesUInt32() + 1))
}
header.SetVersion(1)
return header
}
示例3: CreateTestAnchorEnry
func CreateTestAnchorEnry(dBlock *directoryBlock.DirectoryBlock) *entryBlock.Entry {
answer := entryBlock.NewEntry()
answer.ChainID = GetAnchorChainID()
answer.Version = 0
answer.ExtIDs = nil
height := dBlock.GetHeader().GetDBHeight()
ar := anchor.CreateAnchorRecordFromDBlock(dBlock)
ar.Bitcoin = new(anchor.BitcoinStruct)
ar.Bitcoin.Address = "1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1"
ar.Bitcoin.TXID = fmt.Sprintf("%x", IntToByteSlice(int(height)))
ar.Bitcoin.BlockHeight = int32(height)
ar.Bitcoin.BlockHash = fmt.Sprintf("%x", IntToByteSlice(255-int(height)))
ar.Bitcoin.Offset = int32(height % 10)
hex, err := ar.MarshalAndSign(NewPrimitivesPrivateKey(0))
if err != nil {
panic(err)
}
answer.Content = primitives.ByteSlice{Bytes: hex}
return answer
}
示例4: FetchDirectoryBlockHead
func (db *Overlay) FetchDirectoryBlockHead() (interfaces.IDirectoryBlock, error) {
blk := new(directoryBlock.DirectoryBlock)
block, err := db.FetchChainHeadByChainID(DIRECTORYBLOCK, primitives.NewHash(blk.GetChainID().Bytes()), blk)
if err != nil {
return nil, err
}
if block == nil {
return nil, nil
}
return block.(interfaces.IDirectoryBlock), nil
}
示例5: CreateTestDirectoryBlock
func CreateTestDirectoryBlock(prevBlock *directoryBlock.DirectoryBlock) *directoryBlock.DirectoryBlock {
dblock := new(directoryBlock.DirectoryBlock)
dblock.SetHeader(CreateTestDirectoryBlockHeader(prevBlock))
de := new(directoryBlock.DBEntry)
de.ChainID = primitives.NewZeroHash()
de.KeyMR = primitives.NewZeroHash()
err := dblock.SetDBEntries(append(make([]interfaces.IDBEntry, 0, 5), de))
if err != nil {
panic(err)
}
//dblock.GetHeader().SetBlockCount(uint32(len(dblock.GetDBEntries())))
return dblock
}