Link.fromProto constructor
- PBLink proto
Creates a Link from a standard PBLink proto.
Implementation
factory Link.fromProto(dag_proto.PBLink proto) {
// Hash in PBLink is strictly a CID (multihash or multibase bytes)
CID cid;
try {
cid = CID.fromBytes(Uint8List.fromList(proto.hash));
} catch (_) {
// Fallback for empty or invalid hashes
cid = CID.v0(Uint8List(32));
}
return Link(name: proto.name, cid: cid, size: proto.size.toInt());
}