validate method
override
Validates the block's content hash matches its CID.
Returns true if the hash matches, false otherwise.
Implementation
@override
Future<bool> validate() async {
try {
final computedCid = await CID.fromContent(data, codec: format);
final computedMh = computedCid.multihash.toBytes();
final expectedMh = cid.multihash.toBytes();
if (computedMh.length != expectedMh.length) return false;
for (var i = 0; i < computedMh.length; i++) {
if (computedMh[i] != expectedMh[i]) return false;
}
return true;
} catch (e) {
return false;
}
}