toCid method
CID
toCid()
ToCid encodes a peer ID as a CID of the public key.
Implementation
cid_lib.CID toCid() { // Return type updated to aliased CID
if (_multihash == null || _multihash!.isEmpty) {
throw StateError('Cannot convert invalid PeerId to CID: multihash is empty or null.');
}
// Create a CIDv1 with libp2p-key codec and the peer's multihash.
// Use constant CID.V1 for version.
// Use cid_lib.codecs map for codec constant.
return cid_lib.CID(cid_lib.CID.V1, cid_lib.codecNameToCode['libp2p-key']!, _multihash!);
}