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 }
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 }
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 }
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 }
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 }