本文整理匯總了Golang中github.com/FactomProject/factomd/common/primitives.NewZeroHash函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewZeroHash函數的具體用法?Golang NewZeroHash怎麽用?Golang NewZeroHash使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewZeroHash函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: New
func (c *DirectoryBlock) New() interfaces.BinaryMarshallableAndCopyable {
dBlock := new(DirectoryBlock)
dBlock.Header = NewDBlockHeader()
dBlock.DBHash = primitives.NewZeroHash()
dBlock.KeyMR = primitives.NewZeroHash()
return dBlock
}
示例3: 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
}
示例4: TestAuthoritySignature
func TestAuthoritySignature(t *testing.T) {
s := testHelper.CreateAndPopulateTestState()
idindex := s.CreateBlankFactomIdentity(primitives.NewZeroHash())
s.Identities[idindex].ManagementChainID = primitives.NewZeroHash()
index := s.AddAuthorityFromChainID(primitives.NewZeroHash())
s.Authorities[index].SigningKey = *(s.GetServerPublicKey())
s.Authorities[index].Status = 1
ack := new(messages.Ack)
ack.DBHeight = s.LLeaderHeight
ack.VMIndex = 1
ack.Minute = byte(5)
ack.Timestamp = s.GetTimestamp()
ack.MessageHash = primitives.NewZeroHash()
ack.LeaderChainID = s.IdentityChainID
ack.SerialHash = primitives.NewZeroHash()
err := ack.Sign(s)
if err != nil {
t.Error("Authority Test Failed when signing message")
}
msg, err := ack.MarshalForSignature()
if err != nil {
t.Error("Authority Test Failed when marshalling for sig")
}
sig := ack.GetSignature()
server, err := s.Authorities[0].VerifySignature(msg, sig.GetSignature())
if !server || err != nil {
t.Error("Authority Test Failed when checking sigs")
}
}
示例5: UnmarshalBinaryData
//
// UnmarshalBinaryData for FullServerFault
//
func (m *FullServerFault) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling With Signatures Invalid Server Fault: %v", r)
}
}()
newData = data
if newData[0] != m.Type() {
return nil, fmt.Errorf("Invalid Message type")
}
newData = newData[1:]
if m.ServerID == nil {
m.ServerID = primitives.NewZeroHash()
}
newData, err = Unmarshall(m.ServerID, err, newData)
if m.AuditServerID == nil {
m.AuditServerID = primitives.NewZeroHash()
}
newData, err = m.AuditServerID.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.VMIndex, newData = newData[0], newData[1:]
m.DBHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
m.Height, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
m.SystemHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
m.Timestamp = new(primitives.Timestamp)
newData, err = m.Timestamp.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.SSerialHash = primitives.NewZeroHash()
newData, err = m.SSerialHash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
newData, err = m.SignatureList.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
if len(newData) > 0 {
m.Signature = new(primitives.Signature)
newData, err = m.Signature.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
}
return newData, nil
}
示例6: NewECBlockHeader
func NewECBlockHeader() *ECBlockHeader {
h := new(ECBlockHeader)
h.BodyHash = primitives.NewZeroHash()
h.PrevHeaderHash = primitives.NewZeroHash()
h.PrevFullHash = primitives.NewZeroHash()
h.HeaderExpansionArea = make([]byte, 0)
return h
}
示例7: NewDBlockHeader
func NewDBlockHeader() *DBlockHeader {
d := new(DBlockHeader)
d.BodyMR = primitives.NewZeroHash()
d.PrevKeyMR = primitives.NewZeroHash()
d.PrevLedgerKeyMR = primitives.NewZeroHash()
return d
}
示例8: NewEBlockHeader
// NewEBlockHeader initializes a new empty Entry Block Header.
func NewEBlockHeader() *EBlockHeader {
e := new(EBlockHeader)
e.ChainID = primitives.NewZeroHash()
e.BodyMR = primitives.NewZeroHash()
e.PrevKeyMR = primitives.NewZeroHash()
e.PrevLedgerKeyMR = primitives.NewZeroHash()
return e
}
示例9: NewDirBlockInfo
func NewDirBlockInfo() *DirBlockInfo {
dbi := new(DirBlockInfo)
dbi.DBHash = primitives.NewZeroHash()
dbi.BTCTxHash = primitives.NewZeroHash()
dbi.BTCBlockHash = primitives.NewZeroHash()
dbi.DBMerkleRoot = primitives.NewZeroHash()
return dbi
}
示例10: newDirBlockInfoCopy
func newDirBlockInfoCopy() *dirBlockInfoCopy {
dbi := new(dirBlockInfoCopy)
dbi.DBHash = primitives.NewZeroHash()
dbi.BTCTxHash = primitives.NewZeroHash()
dbi.BTCBlockHash = primitives.NewZeroHash()
dbi.DBMerkleRoot = primitives.NewZeroHash()
return dbi
}
示例11: NewECBlockHeader
func NewECBlockHeader() *ECBlockHeader {
h := new(ECBlockHeader)
h.ECChainID = primitives.NewZeroHash()
h.ECChainID.SetBytes(constants.EC_CHAINID)
h.BodyHash = primitives.NewZeroHash()
h.PrevHeaderHash = primitives.NewZeroHash()
h.PrevLedgerKeyMR = primitives.NewZeroHash()
h.HeaderExpansionArea = make([]byte, 0)
return h
}
示例12: NewAdminBlock
func NewAdminBlock(prev interfaces.IAdminBlock) interfaces.IAdminBlock {
block := new(AdminBlock)
block.Header = new(ABlockHeader)
if prev != nil {
block.Header.SetPrevBackRefHash(primitives.NewZeroHash())
block.Header.SetDBHeight(prev.GetDBHeight() + 1)
} else {
block.Header.SetPrevBackRefHash(primitives.NewZeroHash())
}
return block
}
示例13: UnmarshalDBlock
func UnmarshalDBlock(data []byte) (interfaces.IDirectoryBlock, error) {
dBlock := new(DirectoryBlock)
dBlock.Header = NewDBlockHeader()
dBlock.DBHash = primitives.NewZeroHash()
dBlock.KeyMR = primitives.NewZeroHash()
err := dBlock.UnmarshalBinary(data)
if err != nil {
return nil, err
}
return dBlock, nil
}
示例14: NewDirBlockInfoFromDirBlock
// NewDirBlockInfoFromDirBlock creates a DirDirBlockInfo from DirectoryBlock
func NewDirBlockInfoFromDirBlock(dirBlock interfaces.IDirectoryBlock) *DirBlockInfo {
dbic := new(DirBlockInfo)
dbic.DBHash = dirBlock.GetHash()
dbic.DBHeight = dirBlock.GetDatabaseHeight()
dbic.DBMerkleRoot = dirBlock.GetKeyMR()
dbic.Timestamp = int64(dirBlock.GetHeader().GetTimestamp()) // * 60 ???
dbic.BTCTxHash = primitives.NewZeroHash()
dbic.BTCBlockHash = primitives.NewZeroHash()
dbic.BTCConfirmed = false
return dbic
}
示例15: NewCommitChain
func NewCommitChain() *CommitChain {
c := new(CommitChain)
c.Version = 0
c.MilliTime = new(primitives.ByteSlice6)
c.ChainIDHash = primitives.NewZeroHash()
c.Weld = primitives.NewZeroHash()
c.EntryHash = primitives.NewZeroHash()
c.Credits = 0
c.ECPubKey = new(primitives.ByteSlice32)
c.Sig = new(primitives.ByteSlice64)
return c
}