validate () {
// Get info for type ID, throws on error
TypeRegistry.findByTypeId(this.getTypeId())
// Bitmask can have at most 32 bits with current implementation
if (this.getSubtypes() > Condition.MAX_SAFE_SUBTYPES) {
throw new Error('Bitmask too large to be safely represented')
}
// Assert all requested features are supported by this implementation
if (this.getSubtypes() & ~Condition.SUPPORTED_SUBTYPES) {
throw new Error('Condition requested unsupported feature suites')
}
// Assert the requested fulfillment size is supported by this implementation
if (this.getCost() > Condition.MAX_COST) {
throw new Error('Condition requested too large of a max fulfillment size')
}
return true
}
Given that subtypes is a set of strings, e.g.: Set {'preimage-sha-256', 'ed25519-sha-256'} what is the purpose of the checks > and & ~?
The code for validating a condition is :
Given that
subtypes
is a set of strings, e.g.:Set {'preimage-sha-256', 'ed25519-sha-256'}
what is the purpose of the checks>
and& ~
?