本文整理匯總了Golang中github.com/FactomProject/factomd/common/primitives.Signature類的典型用法代碼示例。如果您正苦於以下問題:Golang Signature類的具體用法?Golang Signature怎麽用?Golang Signature使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Signature類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UnmarshalBinaryData
func (m *DirectoryBlockSignature) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
newData = data
if newData[0] != m.Type() {
return nil, fmt.Errorf("Invalid Message type")
}
newData = newData[1:]
// TimeStamp
m.Timestamp = new(primitives.Timestamp)
newData, err = m.Timestamp.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.SysHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
hash := new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.SysHash = hash
m.DBHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
m.VMIndex, newData = int(newData[0]), newData[1:]
header := directoryBlock.NewDBlockHeader()
newData, err = header.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.DirectoryBlockHeader = header
hash = new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.ServerIdentityChainID = hash
//if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.DBSignature = sig
//}
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return nil, nil
}
示例2: UnmarshalBinaryData
func (m *DirectoryBlockSignature) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling: %v", r)
}
}()
newData = data[1:]
m.DirectoryBlockHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
hash := new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.DirectoryBlockKeyMR = hash
hash = new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.ServerIdentityChainID = hash
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return nil, nil
}
示例3: UnmarshalBinaryData
func (m *Ack) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling: %v", r)
}
}()
newData = data[1:]
m.ServerIndex = (int)(newData[0])
newData = newData[1:]
newData, err = m.Timestamp.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.MessageHash = new(primitives.Hash)
newData, err = m.MessageHash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return
}
示例4: UnmarshalBinaryData
func (m *EOM) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling EOM message: %v", r)
}
}()
newData = data
if newData[0] != m.Type() {
return nil, fmt.Errorf("Invalid Message type")
}
newData = newData[1:]
m.Timestamp = new(primitives.Timestamp)
newData, err = m.Timestamp.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.ChainID = primitives.NewHash(constants.ZERO_HASH)
newData, err = m.ChainID.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Minute, newData = newData[0], newData[1:]
if m.Minute < 0 || m.Minute >= 10 {
return nil, fmt.Errorf("Minute number is out of range")
}
m.VMIndex = int(newData[0])
newData = newData[1:]
m.FactoidVM = uint8(newData[0]) == 1
newData = newData[1:]
m.DBHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
m.SysHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
m.SysHash = primitives.NewHash(constants.ZERO_HASH)
newData, err = m.SysHash.UnmarshalBinaryData(newData)
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return data, nil
}
示例5: NewDBSignatureEntry
// Create a new DB Signature Entry
func NewDBSignatureEntry(identityAdminChainID interfaces.IHash, sig interfaces.IFullSignature) (*DBSignatureEntry, error) {
e := new(DBSignatureEntry)
e.IdentityAdminChainID = identityAdminChainID
bytes, err := sig.MarshalBinary()
if err != nil {
return nil, err
}
prevDBSig := new(primitives.Signature)
prevDBSig.SetPub(bytes[:32])
err = prevDBSig.SetSignature(bytes[32:])
if err != nil {
return nil, err
}
e.PrevDBSig = *prevDBSig
return e, nil
}
示例6: UnmarshalBinaryData
func (m *Heartbeat) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling HeartBeat: %v", r)
}
}()
newData = data
if newData[0] != m.Type() {
return nil, fmt.Errorf("Invalid Message type")
}
newData = newData[1:]
m.Timestamp = new(primitives.Timestamp)
newData, err = m.Timestamp.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.SecretNumber, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
hash := new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.DBlockHash = hash
hash = new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.IdentityChainID = hash
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return nil, nil
}
示例7: UnmarshalBinaryData
func (sl *SigList) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling SigList in Full Server Fault: %v", r)
}
}()
newData = data
sl.Length, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
for i := sl.Length; i > 0; i-- {
tempSig := new(primitives.Signature)
newData, err = tempSig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
sl.List = append(sl.List, tempSig)
}
return newData, nil
}
示例8: UnmarshalBinaryData
func (m *Heartbeat) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling: %v", r)
}
}()
data = data[1:] // skip type
newData, err = m.Timestamp.UnmarshalBinaryData(data)
if err != nil {
return nil, err
}
hash := new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(data)
if err != nil {
return nil, err
}
m.DBlockHash = hash
hash = new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.IdentityChainID = hash
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return nil, nil
}
示例9: UnmarshalBinaryData
func (m *EOM) UnmarshalBinaryData(data []byte) (newData []byte, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Error unmarshalling: %v", r)
}
}()
newData = data[1:]
newData, err = m.Timestamp.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Minute, newData = newData[0], newData[1:]
if m.Minute < 0 || m.Minute >= 10 {
return nil, fmt.Errorf("Minute number is out of range")
}
m.DirectoryBlockHeight, newData = binary.BigEndian.Uint32(newData[0:4]), newData[4:]
hash := new(primitives.Hash)
newData, err = hash.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.IdentityChainID = hash
if len(newData) > 0 {
sig := new(primitives.Signature)
newData, err = sig.UnmarshalBinaryData(newData)
if err != nil {
return nil, err
}
m.Signature = sig
}
return data, nil
}