CID.create constructor
Creates a CID instance from a version, codec name, and pre-computed multihash.
This is a lower-level constructor useful when you already have the multihash.
version
: The CID version (CID.V0 or CID.V1).codecName
: The string name of the multicodec (e.g., "dag-pb", "raw").multihash
: TheUint8List
containing the full multihash bytes.
Throws ArgumentError if the codecName
is unknown or if parameters
violate CID version constraints (e.g., CIDv0 with non-'dag-pb' codec).
Implementation
factory CID.create(int version, String codecName, Uint8List multihash) {
final codecCode = codecNameToCode[codecName];
if (codecCode == null) {
throw ArgumentError('Unknown codec name: $codecName');
}
return CID(version, codecCode, multihash);
}