MCPcopy
hub / github.com/aceld/zinx / decode

Method decode

zdecoder/htlvcrcdecoder.go:92–116  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

90}
91
92func (hcd *HtlvCrcDecoder) decode(data []byte) *HtlvCrcDecoder {
93 datasize := len(data)
94
95 htlvData := HtlvCrcDecoder{
96 Data: data,
97 }
98
99 // Parse the header
100 htlvData.Head = data[0]
101 htlvData.Funcode = data[1]
102 htlvData.Length = data[2]
103 htlvData.Body = data[3 : datasize-2]
104 htlvData.Crc = data[datasize-2 : datasize]
105
106 // CRC
107 if !CheckCRC(data[:datasize-2], htlvData.Crc) {
108 zlog.Ins().DebugF("crc check error %s %s\n", hex.EncodeToString(data), hex.EncodeToString(htlvData.Crc))
109 return nil
110 }
111
112 //zlog.Ins().DebugF("2htlvData %s \n", hex.EncodeToString(htlvData.data))
113 //zlog.Ins().DebugF("HTLVCRC-DecodeData size:%d data:%+v\n", unsafe.Sizeof(htlvData), htlvData)
114
115 return &htlvData
116}
117
118func (hcd *HtlvCrcDecoder) Intercept(chain ziface.IChain) ziface.IcResp {
119 //1. Get the IMessage of zinx

Callers 1

InterceptMethod · 0.95

Calls 3

InsFunction · 0.92
CheckCRCFunction · 0.85
DebugFMethod · 0.65

Tested by

no test coverage detected