UnmarshalBinary does the deserialization.
(keyBytes []byte)
| 170 | |
| 171 | // UnmarshalBinary does the deserialization. |
| 172 | func (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. |