isBlocked method
- CID cid
Returns true if the CID is blocked.
Matching is codec- and version-agnostic (CIDv0 and CIDv1 share the
multihash) and also covers // double-hash entries and /ipfs/CID/*
prefix rules, which block the CID itself.
Implementation
bool isBlocked(CID cid) {
if (!_config.enableDenylist) return false;
final multihashHex = _multihashHex(cid.multihash);
if (_snapshot.multihashHexes.contains(multihashHex) ||
_snapshot.cidStrings.contains(cid.encode())) {
return true;
}
// Path rules that match the empty path (e.g. `/ipfs/CID/*`) also block
// the CID itself.
if (_evalPathRules(_snapshot.ipfsPathRules[multihashHex], '') == true) {
return true;
}
return _matchesHashedCid(cid, '');
}