MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / UnmarshalBinary

Method UnmarshalBinary

proto/nodeinfo.go:172–185  ·  view source on GitHub ↗

UnmarshalBinary does the deserialization.

(keyBytes []byte)

Source from the content-addressed store, hash-verified

170
171// UnmarshalBinary does the deserialization.
172func (id *NodeID) UnmarshalBinary(keyBytes []byte) (err error) {
173 // for backward compatible
174 if len(keyBytes) == 64 {
175 *id = NodeID(keyBytes)
176 return
177 }
178 h, err := hash.NewHash(keyBytes)
179 if err != nil {
180 log.Error("load 32 bytes nodeID failed")
181 return
182 }
183 *id = NodeID(h.String())
184 return
185}
186
187// InitNodeCryptoInfo generate Node asymmetric key pair and generate Node.NonceInfo.
188// Node.ID = Node.NonceInfo.Hash.

Callers 1

TestNodeID_MarshalBinaryFunction · 0.95

Calls 4

StringMethod · 0.95
NewHashFunction · 0.92
ErrorFunction · 0.92
NodeIDTypeAlias · 0.85

Tested by 1

TestNodeID_MarshalBinaryFunction · 0.76